Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
RememberModule.php
1 <?php
2 
3 /**
4  * Gentics Portal.Node PHP
5  * Author & Copyright (c) by Gentics Software GmbH
6  * sales@gentics.com
7  * http://www.gentics.com
8  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
9  * You must not use this software without a valid license agreement.
10  *
11  * RememberModule
12  * This module allows user to remember pages he was visited and then share them using Facebook, mail or printing
13  *
14  * Interaction with module performs with two widgets and one link creation function
15  * Widgets:
16  * - LastRemembered - displays last N remembered pages
17  * - ShareRemembered - allows deleting, sorting, search and share remembered links
18  *
19  * RememberModule::createLink() function creates special link for page. When user clicks on it then page with parametrs remembered in database.
20  *
21 **/
22 class RememberModule extends CWebModule
23 {
24  /**
25  * This key used for making digital signature, which not allows user to change data
26  *
27  * @var string
28  **/
29  public $signSalt = 'sign-salt';
30 
31  /**
32  * Email used as "Send From:" in sharing by email
33  *
34  * @var string
35  **/
36  public $shareByMailEmail = 'remember@example.com';
37 
38  /**
39  * Subject used in sharing by email
40  *
41  * @var string
42  **/
43  public $shareByMailSubject = 'Remember subject';
44 
45  /**
46  * Enable/disable share by email feature
47  *
48  * @var boolean
49  **/
50  public $shareByMailEnabled = false;
51 
52  /**
53  * Facebook application id used for sharing using fb API
54  *
55  * @var string
56  **/
57  public $facebookApplicationId;
58 
59 
60  /**
61  * Prevents abuse of the PDF-generator by only rendering allowed URLs
62  *
63  * @var string
64  **/
65  public $allowedURL = "";
66 
67  /**
68  * Name of the generated PDF-File for download or mailing
69  *
70  * @var string
71  **/
72  public $pdfname = "";
73 
74 
75  /**
76  * Where to write the generated PDF-File temporarly
77  *
78  * @var string
79  **/
80  public $tmpFolder;
81 
82  public function init()
83  {
84  $this->setImport(array(
85  'remember.models.*'
86  ));
87  }
88 
89  /**
90  * Get current user collection id
91  *
92  * @return string
93  **/
94  public function getUserCollectionId()
95  {
96  return Yii::app()->user->isGuest ? Yii::app()->session->getSessionId() : Yii::app()->user->id;
97  }
98 
99  /**
100  * Translates a message to the specified language.
101  *
102  * @param string $str message
103  * @param array $params params
104  * @param string $dic dictionary
105  *
106  * @return string
107  */
108  public static function t($str = '', $params = array(), $dic = 'core')
109  {
110  return Yii::t("RememberModule." . $dic, $str, $params);
111  }
112 
113  /**
114  * Make digital signature for string using md5
115  *
116  * @return string
117  **/
118  public function sign($string)
119  {
120  return md5($string . $this->signSalt);
121  }
122 }