From d679a38e9efabb2213c294e8537e020d987cc3fe Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Apr 2012 05:24:45 -0700 Subject: [PATCH] first cut at a testdrive addon --- randplace.tgz | Bin 2090 -> 2059 bytes randplace/randplace.php | 6 +-- testdrive.tgz | Bin 0 -> 1879 bytes testdrive/README.md | 23 +++++++++++ testdrive/testdrive.php | 89 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 testdrive.tgz create mode 100644 testdrive/README.md create mode 100644 testdrive/testdrive.php diff --git a/randplace.tgz b/randplace.tgz index 931781d060a9feb147a03a43f7a5659fd8e874e2..7ab5f0db9d1769808dd0747f587395e7a32f6b15 100755 GIT binary patch literal 2059 zcmV+m2=w@$|{~_+)ZCn(U0m$J6m-2PS`7s*nY zD^=V>S1uGJ*XDYqEjb&cr!HB-UtlUbQQ+TB=CA_M`0MA#>m8ZjD z6PQ7w^I>W9LS=H8Bk?)i?))<|(!+u<5{z6b>!gt>Tr0N%w~}CQa3{w{qpPLg5^1gq zx>|}tW`n@zN7CAJFoH}6Wg(SLCQhdPF0VvnndJ@d3c6jOBWJ2WXk}UN5EfOD5RX1& zIuXbK(7u>mHY8I1ptOtobQ?W}>c_MhlUU+SUqCN{#^h_F{I0V>lt$+I3fV7=&iN$K z#X>EsU_yr0c-`r8(EnOx85_~anN`JI-GgI>dwYBJ7BnTJW9u(_d%FauU5W{Pysiv7 zF4w_5UY>AHBr9?QhC)gY6+7SyZ&8hfGS-nr|Hu4<(kN}fX|PTkgb_lF9GNk!_!9l2 zYP)sJXDh8Qdoi8Qm^AL!4!@`35kYGYUnCy!;j`ADT0JyE#$78=wH5$ir6aIgMATCD z0hxlxtS4a>Edh!F5(9iJ95TjO6p$E+IN_^Rnc^egtE@EW47osj6t%zZGo5vr)uMi* z{mnHr|1+G~SHF|JzsoMp^l~XpFA7LP5I5uz5`5f@yDn0HxfQ7944-Nfurd@k>~R}> z9E!u5jeI?=7;1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Vf4?@B!=b12Bls}jsefC z(=(`R9A|7L$XF-PYnhLoMT%2EdC{rF1$M0`7nC&IVZFC2FOcR6$~m z9XswkjI%IC+;)k2I%GIaRZh%Qj9JH9h#8xaxh#e{C6?u`7e~nO6Y;<FE4ey>{j@5RGw-`a>4DT$S>m(*3F$jnGiem9&^{vqrY<-FN??{xSl zj1I`~4;4ZpU1qlH)gH8g!e`x9QJGPoE4ki?W905o6=&{rEBkowyHoBJoI2)F|MoyF z;nxVbxxkFp4di;O(ryN!!&7(ztiU44(w*5)uP@#@<5&jill#3?;JZOlB1923*926$ zmDeIsv11$&vD16LbRs!nnZ?5y^c(A}$4*TzO@q3jFsxM=Dh_NsL*hPBw&P8-#7ifi??NB+$cF5uLuT5_S2qww{c3FaMM4E-xDQ(?0ljCJqzvYn?BZ zEi_bpDfXeQ{{3SC>h5E3_B(~Enjeh~GiP;nVQ&*ztfaKAqh$oJWMv_j(oA9D z^2~a8PJ1rHl}(eC6j(~2kMC*E6O~9Wre34k31tIkL z)sN_TE(%#1>J9r44jyhua64@a14w18#94rm4`6Uklff_Mmn`t!{)^nB*Q(M`3F5NC z)YqUCL2VQz+k53QAAhW1Y(ff`i%ztX(G_p*b}LN>@B&H2ubc(`A;7s42&>l>&I^@7 z`2Ovy|5PcF?^RJ_$JoUUtDXlQeNoFj)fM&x*P*AGa<+l%b~T)z)0!@gx{XzX+Mrm~K; ztR1N`E>iJEtsZ5~XR4bm$$&_##F-Ig0HIfL z8nrA;GB7W##hd!cWI6FVsBrH6a`wB`d)6OT^P9ER&iT+@INm#OcV*yBZyflr_ji9C z_Qj0{=2^!p6UDFd;V^%XA5&qF7Z2we2`0tq3C(_3(^t{nJzdnP{N1i^$98PTc5KIXY{zzN U$98PTc6?Fe|C!$Z?EokM0AEBV7XSbN diff --git a/randplace/randplace.php b/randplace/randplace.php index df713766c..b70c02d94 100755 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -8,10 +8,8 @@ * * * - * Addons are registered with the system in the - * .htconfig.php file. - * - * $a->config['system']['addon'] = 'plugin1,plugin2,etc.'; + * Addons are registered with the system through the admin + * panel. * * When registration is detected, the system calls the plugin * name_install() function, located in 'addon/name/name.php', diff --git a/testdrive.tgz b/testdrive.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7d314ea28fedfdfdd21653a06b8e1cd1e00457bd GIT binary patch literal 1879 zcmV-d2dMZTiwFSfcZE*?1MOICZ`(!^_E+;)%n42?rH~xwIn``S174u3l(aX|K4{cfe^N*w%75^UUkc*vi7jM%~KR&R<4t(D89^ zr`tO`?sgA%+P$Oh(P77(&uORAIX>)kj}MLyaNap+x4S#k`|BXBs4T27L_4X7Cd%BZ z>+wJA9(8u8{ne3d zp#Ssu4-o%zj(>2rpdbhai>x43kf7H_$t+fppgbujDxC#YhYW>U2e45i(C6cTrktF&KY7g4bG$V)Kdo7nnX&Ca4 z8O3re%EVHptH?Y9W5;uq!K?tfB2h?Z+}zFV{K%?XXE$7-VmKRGXY8V2FqOsy2%>eK zYh%ky*%>2~pDY5#4xF2}bYxkmY~qdcN}6=Bf`wC{5lNH22MjZ3DHb7{ham9bkKpc! zq_H+sNK{TFp)g+PW-}@VBhZP4W*6|0NJJJn?5R*Ni9OJy!3q^W%1a}YnUn7n19%`P zQK@2glL<1&l*Jv@S}SQTQFuu-p@LjZF0| z%!xD?69a=Sgnsl$wCexMzc|Ogs*XSC|GndGZ_)p|z0Lvpf3J7Y-S+>-pqGC~w1c4a z>{&q1=&eZQ2`w{$kIrQg8I^NtpU{=yEPZevv_u@EVycyjDzEgz)eG(hxKnoeyH`e& zHUBJ4;k0&|ZT{Xb?Npl+x>O$}T`s~!FQ?Y#C#}{pfKAj=3zg1ox|M?Y72a+IOp792 znK(o-b4#r^=(ix)HFBa*&Sp5(`eQv@ew{-M_bGI?w!Tm|%&?OE;PuAo0~L|c*`E~a zUV*63n=QgEaL=YPdjzWV5$qy7wltX&V<6+#dhMql&ijK4zHs=Wvx{^cdNIWiAkQd# zQiK?b_(t|np2YsDqE2leV&f6&sLlh4RjFiHx6;^p_|xE9Ao4#mOcURP)bwERJ0uUX z!4hy!-ioBomI9}96Tolu6gzU|9hmfM38VlT$$F@=C@Evvl9{$@Jab`aRP8NfA|s1} z8ylT^v%O&(41Y<0J{-Kcyto?lFMmMBeM4{F4laKDx&Ke<(Ru$J-;_Y_-x)fc=mQLR z=q_fsjxT}d?nCYNiTi|9bC?jDd8|#t*|N)5wTPxT;8|kN7=OH5m0TCbh*_PFcSHCq zq_bDddhNd4?E43HmP_~K?e~K>uip)?-dznYF6R&Ztv+1xRMOO&63!Vh$xKQy0TGsOb;_OSI@PA1LwNq3Y!~Z?o0DW3!VZKX(Sioz=JgE$EnIt9cZ80gpK>0iON2D zPM(6fDn=MIOM?b+pD~|mtHX_qoQ*AvP7_(QFuWEzd;X%`{E$z)9~v%NySqrAGIwM5 zvRr;I@_$e?Uo4x(9QdLpmZ5DpFsA|G_vZkgKb_VLqvOWAe=FUeucv!$-cr`mc5@AW zt1(WcdSJ&@v#t{-LDSzD|q?!6*mM`%VmSK>SGpqwxOOD@R;~*3<{~sTwco_ zAc@7 z_TOjkGpFF5ShlH)$LnS#vM6{D&sLjHlYWsj)w$#?mt^)q&t&YE!^-f+wcxfbK3`ij zu`R~D!ApZ>h>Ln<>zy3AVUMRmw?xALIWcaREp((r!b?vIQNAevO&`?{wb@zRRi; zDt1}7`byr$3+Wfb%E)UpM|f%93eY_;%^GrNt)}L801BpdjVwN^@m-ItbosA|noqFW z&2config['testdrive']['expiredays'] = 30; + +Set this in your .htconfig.php file to allow a 30 day test drive period. By default no expiration period is defined +in case the plugin is activated accidentally. + + +There is no opportunity to extend an expired account using this plugin. Expiration is final. Other plugins may be created +which charge for service and extend the expiration as long as a balance is maintained. This plugin is purely for creating +a limited use test site. + +An email warning will be sent out approximately five days before the expiration occurs. Once it occurs logins and many +system functions are disabled. Five days later the account is removed completely. + \ No newline at end of file diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php new file mode 100644 index 000000000..b7c021a10 --- /dev/null +++ b/testdrive/testdrive.php @@ -0,0 +1,89 @@ + + */ + + + + +function testdrive_install() { + + register_hook('register_account', 'addon/testdrive/testdrive.php', 'testdrive_register_account'); + register_hook('cron', 'addon/testdrive/testdrive.php', 'testdrive_cron'); +} + + +function testdrive_uninstall() { + + unregister_hook('register_account', 'addon/testdrive/testdrive.php', 'testdrive_register_account'); + unregister_hook('cron', 'addon/testdrive/testdrive.php', 'testdrive_cron'); + +} + +function testdrive_register_account($a,$b) { + + $uid = $b; + + $days = get_config('testdrive','expiredays'); + if(! $days) + return; + + $r = q("UPDATE user set account_expires_on = '%s' where uid = %d limit 1", + dbesc(datetime_convert('UTC','UTC','now +' . $days . ' days')), + intval($uid) + ); + +}; + + +function testdrive_cron($a,$b) { + require_once('include/enotify.php'); + + $r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and + expire_notification_sent = '0000-00-00 00:00:00' "); + + if(count($r)) { + foreach($r as $rr) { + notification(array( + 'uid' => $rr['uid'], + 'type' => NOTIFY_SYSTEM, + 'system_type' => 'testdrive_expire', + 'language' => $rr['language'], + 'to_name' => $rr['username'], + 'to_email' => $rr['email'], + 'source_name' => t('Administrator'), + 'source_link' => $a->get_baseurl(), + 'source_photo' => $a->get_baseurl() . '/images/person-80.jpg', + )); + + q("update user set expire_notification_sent = '%s' where uid = %d limit 1", + dbesc(datetime_convert()), + intval($rr['uid']) + ); + + } + } + + $r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY "); + if(count($r)) { + require_once('include/Contact.php'); + foreach($r as $rr) + user_remove($rr['uid']); + + } + +} + +function testdrive_enotify(&$a, &$b) { + if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM + && x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') { + $b['itemlink'] = $a->get_baseurl(); + $b['epreamble'] = $b['preamble'] = sprintf( t('Your account on %s will expire in a few days.'), get_config('system','sitename')); + $b['subject'] = t('Your Friendica test account is about to expire.'); + $b['body'] = sprintf( t("Hi %1\$s,\n\nYour test account on %2\$s will expire in less than five days. We hope you enjoyed this test drive and use this opportunity to find a permanent Friendica website for your integrated social communications. A list of public sites is available at http://dir.friendica.com/siteinfo - and for more information on setting up your own Friendica server please see the Friendica project website at http://friendica.com."), $b['params']['to_name'], "[url=" . $app->config["system"]["url"] . "]" . $app->config["sitename"] . "[/url]"); + } +}