Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit b990c87

Browse files
committed
Display enterprise page on a regular basis.
1 parent 95c31ff commit b990c87

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

core/src/plugins/access.ajxp_conf/ajxp_confActions.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,49 @@
575575
</processing>
576576
</action>
577577
<action name="share_react" forbidOverride="true"></action>
578+
<action name="display_enterprise">
579+
<gui text="ajxp_conf.120" title="ajxp_conf.121" iconClass="icon-lightbulb" src="download_manager.png" hasAccessKey="false">
580+
<context selection="false" dir="false" recycle="hidden" behaviour="hidden"
581+
actionBar="false" contextMenu="false" infoPanel="false" inZip="false">
582+
</context>
583+
</gui>
584+
<processing>
585+
<clientCallback prepareModal="false" dialogOpenForm="enterprise_advertise_block" dialogOkButtonOnly="true" dialogSkipButtons="false">
586+
<dialogOnOpen><![CDATA[
587+
var lang = "en";
588+
if(pydio && pydio.currentLanguage === "fr") lang = "fr";
589+
else if(pydio && pydio.currentLanguage === "de") lang = "de";
590+
$(oForm).down("iframe").src = "https://pydio.com/"+lang+"/switch-pydio-enterprise";
591+
pydio.Controller.DISPLAY_ENTERPRISE_PING = true;
592+
]]></dialogOnOpen>
593+
<dialogOnComplete hideDialog="true"><![CDATA[]]></dialogOnComplete>
594+
</clientCallback>
595+
<clientForm id="enterprise_advertise_block"><![CDATA[
596+
<div id="enterprise_advertise_block" box_width="70%" box_padding="0" box_height="80%" box_resize="true" style="height:100%;" class="vertical_layout">
597+
<iframe style="width: 100%; height: 90%; border: 0px solid #ddd;" class="vertical_fit"></iframe>
598+
<div style="padding:20px;">&nbsp;</div>
599+
</div>
600+
]]></clientForm>
601+
<clientListener name="init"><![CDATA[
602+
var conn = new Connexion();
603+
conn.addParameter("get_action", "display_enterprise");
604+
conn.onComplete = function(transport){
605+
var response = transport.responseJSON;
606+
if(response && response.display){
607+
pydio.Controller.fireAction("display_enterprise");
608+
}else if(response && !response.display){
609+
pydio.Controller.DISPLAY_ENTERPRISE_PING = true;
610+
}
611+
};
612+
window.setTimeout(function(){
613+
if(!pydio.Controller.DISPLAY_ENTERPRISE_PING){
614+
conn.sendAsync();
615+
}
616+
}, 5000);
617+
]]></clientListener>
618+
<serverCallback methodName="displayEnterprise"/>
619+
</processing>
620+
</action>
578621
</actions>
579622
<client_configs>
580623
<component_config className="InfoPanel">

core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,39 @@ public function switchAction($action, $httpVars, $fileVars)
21062106
return;
21072107
}
21082108

2109+
/**
2110+
* @param $actionName
2111+
* @param $httpVars
2112+
* @param $fileVars
2113+
* @throws Exception
2114+
*/
2115+
public function displayEnterprise($actionName, $httpVars, $fileVars){
2116+
2117+
$touchFile = $this->getPluginWorkDir(true).DIRECTORY_SEPARATOR."enterprise-display";
2118+
HTMLWriter::charsetHeader("application/json");
2119+
if(file_exists($touchFile)){
2120+
$lastDisplay = intval(file_get_contents($touchFile));
2121+
if(time() - $lastDisplay > 60 * 60 * 24 * 15){
2122+
echo json_encode(["display" => true]);
2123+
file_put_contents($touchFile, time());
2124+
}else{
2125+
echo json_encode(["display" => false]);
2126+
}
2127+
}else{
2128+
echo json_encode(["display" => true]);
2129+
file_put_contents($touchFile, time());
2130+
}
2131+
}
21092132

2133+
/**
2134+
* @param $dir
2135+
* @param null $root
2136+
* @param null $hash
2137+
* @param bool $returnNodes
2138+
* @param string $file
2139+
* @param null $aliasedDir
2140+
* @return array
2141+
*/
21102142
public function listPlugins($dir, $root = NULL, $hash = null, $returnNodes = false, $file="", $aliasedDir=null)
21112143
{
21122144
$dir = "/$dir";

0 commit comments

Comments
 (0)