Links in all templates reworked, Primera API (see www.primusportal.de for details...
authorRoland Häder <roland@mxchange.org>
Mon, 18 Aug 2008 22:35:07 +0000 (22:35 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 18 Aug 2008 22:35:07 +0000 (22:35 +0000)
16 files changed:
.gitattributes
application/blog/templates/de/code/action_login_logout.ctp
application/blog/templates/de/code/block_persona_data.ctp
application/blog/templates/de/code/confirm_link.ctp
application/blog/templates/de/code/login_failed.ctp
application/blog/templates/de/code/login_form.ctp
application/blog/templates/de/code/login_main.ctp
application/blog/templates/de/code/logout_done.ctp
application/ship-simu/templates/de/code/action_login_logout.ctp
application/ship-simu/templates/de/code/block_persona_data.ctp
application/ship-simu/templates/de/code/confirm_link.ctp
application/ship-simu/templates/de/code/login_failed.ctp
application/ship-simu/templates/de/code/login_form.ctp
application/ship-simu/templates/de/code/login_main.ctp
application/ship-simu/templates/de/code/logout_done.ctp
inc/classes/third_party/api/primusportal/class_PrimeraApi.php [new file with mode: 0644]

index bd57ad41c6103a8bf229c63a5338d9250fea8723..c9807202f7f089ff5a15f9dc0016121b0c43e274 100644 (file)
@@ -674,6 +674,7 @@ inc/classes/middleware/io/class_FileIoHandler.php -text
 inc/classes/third_party/.htaccess -text
 inc/classes/third_party/api/.htaccess -text
 inc/classes/third_party/api/primusportal/.htaccess -text
+inc/classes/third_party/api/primusportal/class_PrimeraApi.php -text
 inc/classes/third_party/api/wernisportal/.htaccess -text
 inc/classes/third_party/api/wernisportal/class_WernisApi.php -text
 inc/classes/third_party/php_mailer/.htaccess -text
index 5d1dd3b0be0cdae0c6cfb06c23b04a3fad3aebfc..671b44ff51b9cb15899501269e9a39fcd5c773a4 100644 (file)
@@ -1,9 +1,30 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=blog&amp;page=logout&amp;logout=1');
+
+// Set link text
+$helper->setLinkTextById('logout_now_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=blog&amp;page=login_area');
+
+// Set link text
+$helper->setLinkTextById('return_login_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="logout_box">
        <div id="logout_header">
                Willst du dich wirklich aus dem Blog aussloggen?
        </div>
 
        <div id="logout_links">
-               [<a href="$config[base_url]/index.php?app=blog&amp;page=login_area&amp;action=logout&amp;logout=1">Ja</a>] | [<a href="$config[base_url]/index.php?app=blog&amp;page=login_area">Nein</a>]
+               {?logout_now_link?} | {?return_login_link?}
        </div>
 </div>
index cd203e8ecf33e523332f9ce24cbf9dc33c135696..5911ed76c370d935d925a5859b33dfd04b51d246 100644 (file)
@@ -6,7 +6,7 @@ $helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link', 'ind
 $helperInstance->prefetchValueInstance('user');
 
 // Flush the content out
-//$helperInstance->flushContent();
+$helperInstance->flushContent();
 
 // End of PHP commands
 ?>
index f7f35c53f0185c4cc7265c09eff2f10d1ee2a9b8..95039ecc0cf936b7e3896a426aaee6d833bbfcf2 100644 (file)
@@ -1,3 +1,15 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=blog&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('direct_login_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Best&auml;tigung Deiner Email-Adresse:
 </div>
@@ -9,5 +21,5 @@
 </div>
 
 <div id="content_footer">
-       <a href="$config[base_url]/index.php?app=blog&amp;page=login" title="Direkt zum Login-Formular">Hier geht es direkt zum Login!</a>
+       {?direct_login_link?}
 </div>
index a818ba8920048b2cf0a04075fee6b33c7660d0ce..10d07279cc8c805c2c9b1e94c64a463c6181d8d9 100644 (file)
@@ -1,3 +1,15 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=blog&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('login_retry_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Du bist nicht mehr im Blog eingeloggt!
 </div>
@@ -22,7 +34,7 @@
 
 <div id="content_footer">
        <div id="login_retry">
-               [<a href="$config[base_url]/index.php?app=blog&amp;page=login">Login erneut probieren</a>]
+               {?login_retry_link?}
        </div>
 
        Vielen Dank f&uuml;r deine Mitarbeit! :-)
index 599fbe51adac302a0f35f6e5a0556687bd1e10b8..805f28a7b86c4ef4cc46bfa8fb7f10a96684edcc 100644 (file)
@@ -69,6 +69,15 @@ if ($helper->ifGuestLoginAllowed()) {
        $helper->flushContent();
 }
 
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=blog&amp;page=register');
+
+// Set link text
+$helper->setLinkTextById('register_login_form_link_text');
+
+// Flush the content
+$helper->flushContent();
+
 ?>
 <div id="content_header">
        Einloggen zu <span class="app_name">{?app_full_name?}</span>
@@ -85,5 +94,5 @@ if ($helper->ifGuestLoginAllowed()) {
 </div>
 
 <div id="content_footer">
-       Noch kein Loginaccount? [<a href="$config[base_url]/index.php?app=blog&amp;page=register">Dann hier kostenlos anmelden!</a>]
+       Noch kein Loginaccount? {?register_login_form_link?}
 </div>
index b2ee1f3fc0a44ca1c2cbbf2e5aae86cc38e36ae5..3807d7548b27c249f3f23e45512cb456808fa175 100644 (file)
@@ -62,6 +62,15 @@ if ($blockInstance->getValueInstance()->ifUserIsFounder()) {
 // Flush the content out to a template variable
 $blockInstance->flushContent();
 
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'logout_action_link', 'index.php?app=blog&amp;page=login_area');
+
+// Add action
+$helper->addActionLink('logout', "Ausloggen");
+
+// Flush the content
+$helper->flushContent();
+
 // End of all PHP commands
 ?>
 <div id="content_header">
@@ -82,7 +91,6 @@ $blockInstance->flushContent();
        </div>
 
        <div id="logout_link">
-               [<a href="$config[base_url]/index.php?app=blog&amp;page=login_area&amp;action=logout"
-                title="Aus dem Blog ausloggen">Ausloggen</a>]
+               {?logout_action_link?}
        </div>
 </div>
index 76d44edb5e1f584e624dba09161142e9112dd065..106b2287a2d4509c389f5c1f8a60520343712b35 100644 (file)
@@ -1,7 +1,19 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=blog&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('relogin_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Du bist jetzt aus dem Blog ausgeloggt!
 </div>
 
 <div id="content_body">
-       Du kannst dich nun [<a href="$config[base_url]/index.php?app=blog&amp;page=login">erneut einloggen</a>] oder weiter auf unseren Seiten bleiben. ;-)
+       Du kannst dich nun {?relogin_link}? oder weiter auf unseren Seiten bleiben. ;-)
 </div>
index aa4ca1168d84368d286b951861eeff0932973887..459d305919b09d248d28db371d065b5625b648ac 100644 (file)
@@ -1,9 +1,30 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=ship-simu&amp;page=logout&amp;logout=1');
+
+// Set link text
+$helper->setLinkTextById('logout_now_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=ship-simu&amp;page=login_area');
+
+// Set link text
+$helper->setLinkTextById('return_login_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="logout_box">
        <div id="logout_header">
                Willst du dich wirklich aus dem Spiel aussloggen?
        </div>
 
        <div id="logout_links">
-               [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=login_area&amp;action=logout&amp;logout=1">Ja</a>] | [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=login_area">Nein</a>]
+               {?logout_now_link?} | {?return_login_link?}
        </div>
 </div>
index 003bcf4faf983c293d30d4a6f5df5373f0127cdc..45923dc2bf1753476073f982ad5a91f9de0a4033 100644 (file)
@@ -6,7 +6,7 @@ $helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link', 'ind
 $helperInstance->prefetchValueInstance('user');
 
 // Flush the content out
-//$helperInstance->flushContent();
+$helperInstance->flushContent();
 
 // End of PHP commands
 ?>
index 75a1885204ade85f0660954d0b62465c977b373a..91ae0dc979f8186dce19c1eed6d40ce71f657419 100644 (file)
@@ -1,3 +1,15 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=ship-simu&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('direct_login_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Best&auml;tigung Deiner Email-Adresse:
 </div>
@@ -9,5 +21,5 @@
 </div>
 
 <div id="content_footer">
-       <a href="$config[base_url]/index.php?app=ship-simu&amp;page=login" title="Direkt zum Login-Formular">Hier geht es direkt zum Login!</a>
+       {?direct_login_link?}
 </div>
index 9facf08617775e5f930d44b95418273f94f1535f..e134fb2bab612936d49aae86b6428c03e957caa2 100644 (file)
@@ -1,3 +1,15 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=ship-simu&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('login_retry_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Du bist nicht mehr im Spiel eingeloggt!
 </div>
@@ -22,7 +34,7 @@
 
 <div id="content_footer">
        <div id="login_retry">
-               [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=login">Login erneut probieren</a>]
+               {?login_retry_link?}
        </div>
 
        Vielen Dank f&uuml;r deine Mitarbeit! :-)
index bf6c803127e33f916aa64bd036cbb10acf32c097..0d6b64e928e8b6d0ce2c281c70b76d346fd50658 100644 (file)
@@ -69,6 +69,15 @@ if ($helper->ifGuestLoginAllowed()) {
        $helper->flushContent();
 }
 
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=ship-simu&amp;page=register');
+
+// Set link text
+$helper->setLinkTextById('register_login_form_link_text');
+
+// Flush the content
+$helper->flushContent();
+
 ?>
 <div id="content_header">
        Einloggen zu <span class="app_name">{?app_full_name?}</span>
@@ -85,5 +94,5 @@ if ($helper->ifGuestLoginAllowed()) {
 </div>
 
 <div id="content_footer">
-       Noch kein Spieleaccount? [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=register">Dann hier kostenlos anmelden!</a>]
+       Noch kein Spieleaccount? {?register_login_form_link?}
 </div>
index 81d3c0abbc945b511cc28ba1b709ca7c4079bf5c..bf47313dad9cfb1685389b14e503f46b12ac84fd 100644 (file)
@@ -62,6 +62,15 @@ if ($blockInstance->getValueInstance()->ifUserIsFounder()) {
 // Flush the content out to a template variable
 $blockInstance->flushContent();
 
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'logout_action_link', 'index.php?app=ship-simu&amp;page=login_area');
+
+// Add action
+$helper->addActionLink('logout', "Ausloggen");
+
+// Flush the content
+$helper->flushContent();
+
 // End of all PHP commands
 ?>
 <div id="content_header">
@@ -82,8 +91,7 @@ $blockInstance->flushContent();
        </div>
 
        <div id="logout_link">
-               [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=login_area&amp;action=logout"
-                title="Aus dem Spiel ausloggen">Ausloggen</a>]
+               {?logout_action_link?}
        </div>
 </div>
 
index 9d441da4d7092d5cec148628b90db7f602353dfc..b956f23f8272b7349e0ad2dc2dc71ca2f2baebcb 100644 (file)
@@ -1,7 +1,19 @@
+<?php
+// Get helper instance
+$helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=ship-simu&amp;page=login');
+
+// Set link text
+$helper->setLinkTextById('relogin_link_text');
+
+// Flush the content
+$helper->flushContent();
+
+// [EOF]
+?>
 <div id="content_header">
        Du bist jetzt aus dem Spiel ausgeloggt!
 </div>
 
 <div id="content_body">
-       Du kannst dich nun [<a href="$config[base_url]/index.php?app=ship-simu&amp;page=login">erneut einloggen</a>] oder weiter auf unseren Seiten bleiben. ;-)
+       Du kannst dich nun {?relogin_link?} oder weiter auf unseren Seiten bleiben. ;-)
 </div>
diff --git a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php
new file mode 100644 (file)
index 0000000..fba7463
--- /dev/null
@@ -0,0 +1,240 @@
+<?php
+/**
+ * PrimusInterface
+ * -------------------------------------------
+ * Mit dieser Klasse ist ein einfacher Primeratransfer von Ihrem Account
+ * zu dem Account eines bei Primusportal.de registrierten Mitglieds möglich.
+ *
+ *------------------ Aenderungen durch Roland Haeder 09.08.2008 ----------------
+ * Klasse umbenannt nach PrimeraApi, damit sie in das Framework besser passt.
+ * Zudem sind alle oeffentlichen Attribute nun privat, der Konstruktor hat den
+ * neuen "magischen" Namen __construct() und "normale" Konstanten sind nach
+ * Klassenkonstanten umbenannt. Unsinnige else-Bloecke sind noch umgewandelt.
+ * Methodennamen fangen nun immer mit einem kleinen Buchstaben an. Zudem sind
+ * die Methoden Pay,Query und Parse umbenannt.
+ *------------------ Aenderungen durch Roland Haeder 09.08.2008 ----------------
+ *
+ * Die Einbindung des Interfaces geschieht folgendermaßen:
+ *  1. Einbindung der Klasse in Ihr PHP-Auszahlungsskript:
+ *     CODE:
+ *       require_once( "PFAD/ZU/DER/KLASSE/PrimusInterface.class.php" );
+ *       $PPUsername = "username"; // Ihr Username bei Primusportal
+ *       $PPPassword = "passwort"; // Ihr Passwort bei Primusportal
+ *
+ *       $Interface = new PrimusInterface($PPUsername, $PPPassword);
+ *  2. Durchführen einer Auszahlung:
+ *     CODE:
+ *       $Status = $Interface->payPrimera($PayReceiver, $PayAmount, $PayDescription);
+ *
+ *     Wobei $PayReicer der Username des Empfängers bei
+ *     Primusportal.de ist. $PayAmount ist der gerundete( !! ) Betrag an Primera,
+ *     die der Empfänger erhalten soll. $PayDescription ist eine von Ihnen 
+ *     festgelegte kurze Beschreibung. Die Länge dieses Textes darf 100 Zeichen
+ *     nicht überschreiten. Beispiel:
+ *       $status = $Interface->payPrimera("garbage", 10000, "Auszahlung IhreSeite.de - ID: 12345");
+ *  3. Überprüfung des Status (Rückgabecode):
+ *     CODE:
+ *       if (!$status) {
+ *         // Ein Fehler ist aufgetreten
+ *     // Fehlerbehandlung hier einfügen...
+ *       }else {
+ *         // Auszahlung erfolgreich durchgeführt
+ *         // Führen Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu
+ *         // bestätigen...
+ *       }
+ *
+ *     Die komplette Rückgabe des Interfaces wird als assoziatives Array in der Klassen-
+ *     variable __data gespeichert:
+ *     __data => array("status" => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...),
+ *                     "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgeführt"),
+ *                     ")
+ *
+ *
+ * @author             Andreas Schmidt <xxgarbagexx@web.de>
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            1.0 - beta
+ * @copyright  (c) 2007 by Primusportal.de
+ * @copyright  (c) 2008 by Roland Haeder
+ */
+class PrimeraApi {
+       /**
+        * Fehler - Interfacebenutzer
+        */
+       const PI_ERROR = -1;
+
+       /**
+        * Statuscode für erfolgreich ausgeführte Transaktion
+        */
+       const PI_DONE = 200;
+
+       /**
+        * Fehler - User existiert nicht oder ist gesperrt
+        */
+       const PI_RECEIVER_ERROR = 301;
+
+       /**
+        * Sender-Account Fehler (User nicht existent, gesperrt, ...)
+        */
+       const PI_SENDER_ERROR = 401;
+
+       /**
+        * Betrag fehler
+        */
+       const PI_AMOUNT_ERROR = 501;
+
+       /**
+        * Zu wenig Primera
+        */
+       const PI_TOO_LESS_PRIMERA = 502;
+
+       /**
+        * User nicht aktiv oder existiert nicht
+        */
+       const PI_USER_CHECK_ERROR = 601;
+
+       /**
+        * User aktiv
+        */
+       const PI_USER_CHECK_OK = 602;
+
+       /**
+        * Primerastand erfolgreich geholt
+        */
+       const PI_GET_PRIMERA_DONE = 701;
+
+       /**
+        * URL für das Interface auf dem Primusserver:
+        */
+       private $host = "www.primusportal.de";
+       private $path = "/transfer.interface.2.0.php";
+
+       private $errno = 0;
+       private $err = "";
+
+       private $seperator = ":";
+
+       private $username = "";
+       private $password = "";
+
+       private $data = array();
+
+       /**
+        * Konstruktor
+        */
+       public function __construct ($PPUsername, $PPPassword) {
+               // Call parent constructor
+               parent::__construct();
+
+               // Clean up a little
+               $this->removeSystemArray();
+               $this->removeNumberFormaters();
+
+               // Set data (DEPRECATED!)
+               $this->username = $PPUsername;
+               $this->password = $PPPassword;
+       }
+
+       /**
+        * Anfrage senden und Rückgabecode in Variable speichern
+        */
+       function queryApi ( $data = array() ) {
+               $fp = fsockopen($this->host, 80, $this->errno, $this->_err);
+               if (!$fp) return false;
+
+               $data["PrimusInterface_Username"] = base64_encode($this->username);
+               $data["PrimusInterface_Password"] = base64_encode(md5($this->password));
+
+               // POST-Daten übermitteln:
+               $data = http_build_query($data, '', '&');
+
+               fputs($fp, "POST {$this->path}HTTP/1.1\r\n");
+               fputs($fp, "Host: {$this->host}\r\n");
+               fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
+               fputs($fp, "Content-length: ". strlen($data) ."\r\n");
+               fputs($fp, "Connection: close\r\n\r\n");
+               fputs($fp, $data);
+
+               $return = "";
+               while (!feof($fp)) {
+                       $return.=fgets($fp,128);
+               }
+
+               $content = explode("<!-- return-start -->", $return);
+               return $content[1];
+       }
+
+       /**
+        * Funktion parst die Rückgabe vom Transferskript:
+        */
+       function parseContent ( $content ) {
+               $x = explode("\n", $content);
+               $return = array();
+               foreach($x as $currentLine) {
+                       $line_exploded = explode(":", $currentLine,2);
+                       if (count($line_exploded) > 1) {
+                               $return[$line_exploded[0]] = $line_exploded[1];
+                       }
+               }
+               return $return;
+       }
+
+       /**
+        * @param int/string $Receiver UserID / Username des Empfängers
+        * @param int$Amount Betrag in ganzzahligen Primera
+        * @param string $Description Beschreibung (Sichtbar in Einzelauflistung)
+        */
+       public function payPrimera ($Receiver, $Amount, $Description = "") {
+               $valid = false;
+               $PostData = array("PrimusInterface_Action" => "Pay",
+                       "PrimusInterface_Receiver" => base64_encode($Receiver),
+                       "PrimusInterface_Amount" => base64_encode($Amount),
+                       "PrimusInterface_Description" => base64_encode($Description) );
+
+               $PostReturn = $this->parseContent( $this->queryApi($PostData) );
+
+               $this->data = $PostReturn;
+               if ($PostReturn["status"] == "200") {
+                       $valid = true;
+               }
+               return $valid;
+       }
+
+       /**
+        * Überprüft den Status eines Primus-Users
+        * - existiert der User
+        * - ist er aktiv
+        * @param string/int $User Userid / Username
+        */
+       function CheckPrimusUser($User) {
+               $valid = false;
+               $PostData = array("PrimusInterface_Action"=> "CheckPrimusUser",
+                       "PrimusInterface_CheckPrimusUser" => $User);
+
+               $PostReturn = $this->parseContent( $this->queryApi($PostData) );
+
+               $this->data = $PostReturn;
+
+               if ($PostReturn["status"] == self::PI_USER_CHECK_OK) {
+                       $valid = true;
+               }
+               return $valid;
+       }
+
+       /**
+        * Die Funktion liefer den aktuellen Primerastand
+        */
+       function getPrimera() {
+               $primera = false;
+               $PostData = array( "PrimusInterface_Action" => "GetPrimera" );
+               $PostReturn = $this->parseContent( $this->queryApi($PostData) );
+
+               $this->data = $PostReturn;
+               if ($PostReturn["status"] == self::PI_GET_PRIMERA_DONE) {
+                       $primera = $PostReturn["primera"];
+               }
+               return $primera;
+       }
+}
+
+// [EOF]
+?>
\ No newline at end of file