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  * Facebook application id used for sharing using fb API
47  *
48  * @var string
49  **/
50  public $facebookApplicationId;
51 
52 
53  /**
54  * Prevents abuse of the PDF-generator by only rendering allowed URLs
55  *
56  * @var string
57  **/
58  public $allowedURL = "";
59 
60  /**
61  * Name of the generated PDF-File for download or mailing
62  *
63  * @var string
64  **/
65  public $pdfname = "";
66 
67 
68  /**
69  * Where to write the generated PDF-File temporarly
70  *
71  * @var string
72  **/
73  public $tmpFolder;
74 
75  public function init()
76  {
77  $this->setImport(array(
78  'remember.models.*'
79  ));
80  }
81 
82  /**
83  * Get current user collection id
84  *
85  * @return string
86  **/
87  public function getUserCollectionId()
88  {
89  return Yii::app()->user->isGuest ? Yii::app()->session->getSessionId() : Yii::app()->user->id;
90  }
91 
92  /**
93  * Translates a message to the specified language.
94  *
95  * @param string $str message
96  * @param array $params params
97  * @param string $dic dictionary
98  *
99  * @return string
100  */
101  public static function t($str = '', $params = array(), $dic = 'core')
102  {
103  return Yii::t("RememberModule." . $dic, $str, $params);
104  }
105 
106  /**
107  * Make digital signature for string using md5
108  *
109  * @return string
110  **/
111  public function sign($string)
112  {
113  return md5($string . $this->signSalt);
114  }
115 }