Browse the code

 

Differences between 147 and 148 on /trunk/inc.
Number of edited files: 53 (19 added, 17 deleted and 17 modified)
Revision 148

About 6 years and 7 months ago.

* Added a draft for notification (via mail or jabber)
* Moved all modules classes to a models/ directory
* Added fortune in jabber module
Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
55
55
        // Import configuration
56
56
        $xml = simplexml_load_file($basedir.'/inc/codingteam.cfg');
57
57
        $this->db_type = $xml->db->type;
58
 
        $this->db_path = $xml->db->path;
59
58
        $this->db_hostname = $xml->db->hostname;
60
59
        $this->db_database = $xml->db->database;
61
60
        $this->db_username = $xml->db->username;
149
148

                                        
150
149
        // Class: Database layer
151
150
        require($basedir.'/inc/classes/db.php');
152
 
        $ct_db = new Database($this->db_type, $this->db_path, $this->db_hostname, $this->db_database, 
153
 
                              $this->db_username, $this->db_password, $error);
 
151
        $ct_db = new Database($this->db_type, $this->db_hostname, $this->db_database, $this->db_username,
 
152
                              $this->db_password, $error);
154
153

                                        
155
154
        // Class: Session
156
155
        require($basedir.'/inc/classes/session.php');
157
156

                                        

 

Old New Code
32
32
 */
33
33
class Database
34
34
{
35
 
    private $type, $path, $hostname, $database, $username, $password, $error;
 
35
    private $type, $hostname, $database, $username, $password, $error;
36
36

                                        
37
 
    function __construct($type, $path, $hostname, $database, $username, $password, $error)
 
37
    function __construct($type, $hostname, $database, $username, $password, $error)
38
38
    {
39
39
        $this->error = $error;
40
40

                                        
41
41

                                        

 

Old New Code
384
384

                                        
385
385
        // If a > 0 the page cannot be stored in the cache
386
386
        $a = 0;
387
 
        $nocache_keywords = array('register', 'logout', 'deleteadmin', 'password', 'delete', 'admin', 'new', 'add', 'edit', 'answer', 'search', 'join');
 
387
        $nocache_keywords = array('register', 'logout', 'deleteadmin', 'password', 'delete', 'admin', 'new', 'add', 'edit', 'answer', 'search', 'join', 'vote');
388
388
        foreach ($nocache_keywords as $key)
389
389
            if (in_array($key, $this->page))
390
390
                $a ++;
391
391

                                        

 

Old New Code
50
50
        return count($this->db->select('users', FALSE));
51
51
    }
52
52

                                        
 
53

                                    
 
54
    /**
 
55
     * Add an user
 
56
     *
 
57
     * @param $nickname
 
58
     *   Nickname of the user.
 
59
     * @param $password
 
60
     *   Password of the user.
 
61
     * @param $surname
 
62
     *   Surname of the user.
 
63
     * @param $name
 
64
     *   Name of the user.
 
65
     * @param $mail
 
66
     *   Mail of the user.
 
67
     * @param $jabberid
 
68
     *   Jabber ID of the user.
 
69
     * @param $website
 
70
     *   Website URL of the user.
 
71
     * @param $avatar
 
72
     *   Avatar of the user.
 
73
     * @param $level
 
74
     *   Level of the user.
 
75
     * @param $hash
 
76
     *   Unique hash of the user.
 
77
     * @param $lang
 
78
     *   Speaking-language of the user.
 
79
     * @param $notif
 
80
     *   'jabber', 'mail' or 'none' for notification
 
81
     * @return
 
82
     *   The identifier of the new member.
 
83
     */
53
84
    function addUser($nickname, $password, $surname, $name, $mail, $jabberid, $website, $avatar,
54
 
    $level, $hash, $lang)
 
85
                     $level, $hash, $lang)
55
86
    {
56
87
        return $this->db->insert('users', array('nickname' => $nickname,
57
88
                                                'password' => sha1($password),
64
95
                                                'avatar' => $avatar,
65
96
                                                'level' => $level,
66
97
                                                'keyid' => $hash,
67
 
                                                'lang' => $lang
 
98
                                                'lang' => $lang,
 
99
                                                'notif' => $notif
68
100
                                               ));
69
101
    }
70
102

                                        
 
103

                                    
 
104
    /**
 
105
     * Load an user
 
106
     *
 
107
     * @param $value
 
108
     *   One value that can identify the user (id, nickname or hash).
 
109
     * @param $where
 
110
     *   Database field that corresponds with value.
 
111
     * @return
 
112
     *   A boolean (TRUE if the user is loaded).
 
113
     */
71
114
    function load($id, $where)
72
115
    {
73
116
        if (isset($this->loaded))
89
132
                $this->avatar = $user['avatar'];
90
133
                $this->level = $user['level'];
91
134
                $this->lang = $user['lang'];
 
135
                $this->notif = $user['notif'];
92
136

                                        
93
137
                $this->password = $user['password'];
94
138
                $this->keyid = $user['keyid'];
268
312
        $this->updateField('keyid', $keyid);
269
313
        $this->keyid = $keyid;
270
314
    }
 
315

                                    
 
316
    function getNotif()
 
317
    {
 
318
        if ($this->loaded)
 
319
            return $this->notif;
 
320
    }
 
321

                                    
 
322
    function setNotif($notif)
 
323
    {
 
324
        $this->updateField('notif', $notif);
 
325
        $this->notif = $notif;
 
326
    }
271
327
}
272
328
?>
273
329

                                        

 

Old New Code
106
106
 * and return the class instance.
107
107
 *
108
108
 * @param $id
109
 
 *   Database id of the user.
 
109
 *   Database identifier of the user.
110
110
 * @param $db
111
111
 *   The instance of the database class.
112
112
 * @param $loadby (optional)
113
 
 *   Database field to load from.
 
113
 *   Database field to load from (empty if identifier).
114
114
 * @return
115
115
 *   An instance of User class.
116
116
 */
160
160
        $grep = explode('.', $class);
161
161
        $module = $grep[0];
162
162
        $class = $grep[1];
163
 
        $file = $basedir.'/inc/modules/'.$module.'/'.$class.'.php';
 
163
        $file = $basedir.'/inc/modules/'.$module.'/models/'.$class.'.php';
164
164
    }
165
165

                                        
166
166
    if (!file_exists($file))
167
167

                                        

 

Old New Code
1842
1842

                                        
1843
1843

                                        
1844
1844

                                        
1845
 
class MakeXML extends Jabber
 
1845
class MakeXML extends JabberPHP
1846
1846
{
1847
1847
	var $nodes;
1848
1848

                                        
1849
1849

                                        

 

Old New Code
55
55
        $page = getStaticPage($this->ct_db, 'about');
56
56

                                        
57
57
        if ($page)
58
 
            $this->maincontent = '<h3>'.$page['title'].'</h3><br />'.$page['text'];
 
58
            $this->maincontent = '<h1>'.$page['title'].'</h1><br />'.$page['text'];
59
59
        else
60
60
            $this->maincontent = _('No document.');
61
61

                                        
62
62

                                        

 

Old New Code
55
55
        $page = getStaticPage($this->ct_db, 'tou');
56
56

                                        
57
57
        if ($page)
58
 
            $this->maincontent = '<h3>'.$page['title'].'</h3><br />'.$page['text'];
 
58
            $this->maincontent = '<h1>'.$page['title'].'</h1><br />'.$page['text'];
59
59
        else
60
60
            $this->maincontent = _('No document.');
61
61

                                        
62
62

                                        

 

Old New Code
46
46
            <li '.( ($this->page[2] == 'default') ? 'class="current" style="background-image: url(\'public/images/icons/apps/im-jabber.png\');"' : '' ).'>
47
47
            <a href="jabber/default/nbuser:desc">'._('Chat rooms list').'</a></li>
48
48

                                        
49
 
            <li '.( ($this->page[2] == 'fortunes') ? 'class="current" style="background-image: url(\'public/images/icons/stock/emoticons/stock_smiley-25.png\');"' : '' ).'>
50
 
            <a href="jabber/fortunes">'._('Fortunes').'</a></li>
 
49
            <li '.( ($this->page[2] == 'fortunes') ? 'class="current" style="background-image: url(\'public/images/icons/stock/image/stock_draw-callouts.png\');"' : '' ).'>
 
50
            <a href="jabber/fortunes">'._('Fortunes').'</a>
 
51
            <ul class="submenu">
 
52
              <li><a href="jabber/fortunes">'._('Latest fortunes').'</a></li>
 
53
              <li><a href="jabber/fortunes/top">'._('Top').'</a></li>
 
54
              <li><a href="jabber/fortunes/add"><strong>'._('Add a fortune').'</strong></a></li>
 
55
            </ul></li>
51
56

                                        
52
57
            </ul><div style="margin-bottom: 3.0em;">&nbsp;</div>';
53
58
    }
54
59

                                        

 

Old New Code
35
35
        $this->maincontent = '';
36
36

                                        
37
37
        // Meta tags
38
 
        $this->metatags = array('title'       => _('Jabber'),
 
38
        $this->metatags = array('title'       => _('Chat rooms list - Jabber'),
39
39
                                'feed'         => '',
40
40
                                'description' => '',
41
41
                                'keywords'    => ''
89
89
        $cfg = getClass('config', $this->ct_db);
90
90
        $mucserver = $cfg->get('jabber', 'muc');
91
91

                                        
92
 
        $this->maincontent .= '<h1>'._('Jabber').'</h1>
 
92
        $this->maincontent .= '<h1>'._('Chat rooms list').'</h1>
93
93
        <p>'._("This is the list of all the Jabber rooms of every projects hosted on the forge. You can join them even if you don't have a Jabber account.").'</p>
94
94
        <table style="width: 100%;margin-top: 15px;">
95
95
        <thead><tr>
96
96

                                        

 

Old New Code
36
36

                                        
37
37
        // Meta tags
38
38
        $this->metatags = array('title'       => _('Fortunes - Jabber'),
39
 
                                'feed'         => '',
40
39
                                'description' => '',
41
40
                                'keywords'    => ''
42
41
                               );
43
42

                                        
44
 
        // Load the Jabber class
45
 
        $this->jabber = getClass('jabber.jabber', $this->ct_db);
 
43
        // Add feed
 
44
        if (empty($this->page[3])|| (!in_array($this->page[3], array('show', 'add')) && is_numeric($this->page[3])))
 
45
            $this->metatags['feed'] = 'jabber/fortunes';
 
46

                                    
 
47
        // Fortunes class
 
48
        $this->fortunes = getClass('jabber.fortunes', $this->ct_db);
 
49

                                    
 
50
        // Vote for a fortune
 
51
        if ($this->page[3] == 'vote' && is_numeric($this->page[4]) && in_array($this->page[5], array('good', 'bad')))
 
52
        {
 
53
            if ($this->fortunes->load($this->page[4]) && !isset($_COOKIE['ct-fortune-vote'.$this->page[4]]))
 
54
            {
 
55
                setcookie('ct-fortune-vote'.$this->page[4], $this->page[5], time() + 24 * 60 * 60, '/');  
 
56
                $votes = $this->fortunes->getVote();
 
57

                                    
 
58
                if ($this->page[5] == 'good')
 
59
                    $this->fortunes->setVote($votes + 1);
 
60
                elseif ($this->page[5] == 'bad')
 
61
                    $this->fortunes->setVote($votes - 1);
 
62
            }
 
63
            else
 
64
                $this->error->displayError(_('Fortune not found or vote already counted for today.'), 0);
 
65

                                    
 
66
            deleteCacheVersion('/jabber/fortunes', TRUE);
 
67

                                    
 
68
            global $baseurl;
 
69
            Header('Location: '.$baseurl.'jabber/fortunes/show/'.$this->page[4]);
 
70
        }
 
71
        // Delete a fortune
 
72
        elseif ($this->page[3] == 'delete' && is_numeric($this->page[4]))
 
73
            if ($this->ct_session->isLogged())
 
74
                if (is_level($_SESSION['id'], 'administrator', $this->ct_db) || is_affiliation($_SESSION['id'], $this->id, $this->ct_db))
 
75
                {
 
76
                    $this->fortunes->remove($this->page[4]);
 
77

                                    
 
78
                    deleteCacheVersion('/jabber/fortunes', TRUE);
 
79

                                    
 
80
                    global $baseurl;
 
81
                    Header('Location: '.$baseurl.'jabber/fortunes');
 
82
                }
46
83
    }
47
84

                                        
48
85
    function showFeed()
49
86
    {
 
87
        global $baseurl;
 
88
        $feed_array['title'] = _('Fortunes');
 
89
        $feed_array['link'] = $baseurl.'jabber/fortunes';
 
90
        $feed_array['description'] = _('Latest fortunes.');
 
91

                                    
 
92
        $list = $this->fortunes->getLatestFortunes(0, 5);
 
93

                                    
 
94
        if ($list[1])
 
95
        {
 
96
            for ($i=0; $i<count($list[1]); $i++)
 
97
            {
 
98
                if (!empty($list[1][$i]['unregistered_nick']))
 
99
                    $nick = htmlspecialchars($list[1][$i]['unregistered_nick']);
 
100
                else
 
101
                {
 
102
                    $user = getUser($list[1][$i]['registered_id'], $this->ct_db);
 
103

                                    
 
104
                    $nick = htmlspecialchars($user->getNickname());
 
105
                }
 
106

                                    
 
107
                $feed_array['threads'][$i]['title'] = $list[1][$i]['id'];
 
108
                $feed_array['threads'][$i]['pubDate'] = $list[1][$i]['datetime'];
 
109
                $feed_array['threads'][$i]['guid'] = $baseurl.'jabber/fortunes/show/'.$list[1][$i]['id'];
 
110
                $feed_array['threads'][$i]['link'] = $baseurl.'jabber/fortunes/show/'.$list[1][$i]['id'];
 
111
                $feed_array['threads'][$i]['dc:creator'] = $nick;
 
112
                $feed_array['threads'][$i]['description'] = $this->fortunes->pretty_fortune($list[1][$i]['text']);
 
113
            }
 
114
        }
 
115

                                    
 
116
        return $feed_array;
50
117
    }
51
118

                                        
52
119
    function treatForms()
53
120
    {
 
121
        // Start error handler
 
122
        $this->form_error = 0;
 
123

                                    
 
124
        // Clean POST values
 
125
        foreach ($_POST as $key => $value)
 
126
            if (!is_scalar($value))
 
127
                exit('Error.');
 
128

                                    
 
129
        if ((count($_POST) == 1 || count($_POST) == 4) && !empty($_POST['text']))
 
130
        {
 
131
            $text = $this->ct_db->cleanentry($_POST['text'], FALSE);
 
132

                                    
 
133
            if ($this->ct_session->isLogged())
 
134
            {
 
135
                $unregistered_nick = '';
 
136
                $registered_id = $_SESSION['id'];
 
137
            }
 
138
            else
 
139
            {
 
140
                $unregistered_nick = $this->ct_db->cleanentry($_POST['nickname'], TRUE);
 
141

                                    
 
142
                // No special chars in the nickname
 
143
                if (!ereg("^[0-9A-Za-z_-]+$", $unregistered_nick))
 
144
                    $this->form_error = _('No special characters in nickname (Authorized characters are 0-9, A-Z and a-z).');
 
145

                                    
 
146
                // Captcha
 
147
                $captcha = $this->ct_db->cleanentry($_POST[$_SESSION['captcha']], TRUE);
 
148
                $captcha_ = $this->ct_db->cleanentry($_POST['captcha_'], TRUE);
 
149

                                    
 
150
                // Check captcha
 
151
                if (!ereg("^([0-9a-z]{40})$" , $captcha_))
 
152
                    exit('Error.');
 
153
                if (sha1($captcha + $_SESSION['alea']) != $captcha_)
 
154
                    $this->form_error = _('Please verify the captcha.');
 
155

                                    
 
156
                $registered_id = '';
 
157
            }
 
158

                                    
 
159
            if (!$this->form_error)
 
160
            {
 
161
                $fortune_id = $this->fortunes->add(array('text' => $text,
 
162
                                                         'unregistered_nick' => $unregistered_nick,
 
163
                                                         'registered_id' => $registered_id
 
164
                                                        ));
 
165

                                    
 
166
                deleteCacheVersion('/jabber/fortunes', TRUE);
 
167

                                    
 
168
                global $baseurl;
 
169
                Header('Location: '.$baseurl.'jabber/fortunes/show/'.$fortune_id);
 
170
            }
 
171
        }
54
172
    }
55
173

                                        
56
174
    function showPage()
58
176
        $this->maincontent .= '<h1>'._('Fortunes').'</h1>
59
177
        <a href="jabber/fortunes/add">'._('Add a new fortune').'</a>';
60
178

                                        
 
179
        if ((empty($this->page[3]) || $this->page[3] == 'top') || (!in_array($this->page[3], array('show', 'add')) && is_numeric($this->page[3])))
 
180
        {
 
181
            if (isset($this->page[3]) && $this->page[3] != 'top')
 
182
            {
 
183
                $page = $this->page[3];
 
184
                $page --;
 
185
            }
 
186
            elseif (isset($this->page[4]) && $this->page[3] == 'top')
 
187
            {
 
188
                $page = $this->page[4];
 
189
                $page --;
 
190
            }
61
191

                                        
 
192
            $max = 10;
 
193
            if(!$page)
 
194
            {
 
195
                $start = 0;
 
196
                $page = 0;
 
197
            }
 
198
            else
 
199
                $start = $page * $max;
 
200

                                    
 
201
            if ($this->page[3] == 'top')
 
202
                $fortunes_list = $this->fortunes->getTopFortunes($start, $max);
 
203
            else
 
204
            {
 
205
                $fortunes_list = $this->fortunes->getLatestFortunes($start, $max);
 
206

                                    
 
207
                $this->maincontent .= '<div class="feed" style="background-image: url(\'public/images/feed.png\');">
 
208
                '.sprintf(
 
209
                _('Feed subscription: %s or %s.'), '<a href="rss/jabber/fortunes">'._('RSS').'</a>',
 
210
                '<a href="atom/jabber/fortunes">'._('Atom').'</a>').'
 
211
                </div>';
 
212
            }
 
213

                                    
 
214
            $this->maincontent .= '<h2>'.sprintf(_('Browsing %s fortunes'), $fortunes_list[0]).'</h2>';
 
215

                                    
 
216
            foreach ($fortunes_list[1] as $fortune)
 
217
            {
 
218
                $this->maincontent .= '<div class="fortune">
 
219
                <div class="vote">
 
220
                  <a href="jabber/fortunes/vote/'.$fortune['id'].'/bad"><img src="public/images/icons/actions/list-remove.png" alt="-" style="width: 8px;" /></a>
 
221
                  '.$fortune['vote'].'
 
222
                  <a href="jabber/fortunes/vote/'.$fortune['id'].'/good"><img src="public/images/icons/actions/list-add.png" alt="+" style="width: 8px;" /></a>
 
223
                </div>
 
224

                                    
 
225
                <h1><a href="jabber/fortunes/show/'.$fortune['id'].'">'._('Show this fortune').'</a></h1>
 
226

                                    
 
227
                <p>
 
228
                '.$this->fortunes->pretty_fortune($fortune['text']).'
 
229
                </p>';
 
230

                                    
 
231
                if ($this->ct_session->isLogged())
 
232
                    if (is_level($_SESSION['id'], 'administrator', $this->ct_db) || is_affiliation($_SESSION['id'], $this->id, $this->ct_db))
 
233
                        $this->maincontent .= '<ul style="margin-top: 5px;"><li><a href="jabber/fortunes/delete/'.$fortune['id'].'">'._('Delete this fortune').'</a></li></ul>';
 
234

                                    
 
235
                $this->maincontent .= '</div>'; 
 
236

                                    
 
237
            }
 
238

                                    
 
239
            $this->maincontent .= '<table style="width: 100%;"><tfoot>
 
240
            <tr>
 
241
            <td style="width: 80%;">';
 
242
            $i = 0;
 
243

                                    
 
244
            if($fortunes_list[0] > $max)
 
245
            {
 
246
                while($i < ($fortunes_list[0] / $max))
 
247
                {
 
248
                    if($i != $page)
 
249
                        $this->maincontent .= '&nbsp;<a href="jabber/fortunes/'.( ($this->page[3] == 'top') ? 'top/' : '' ).($i + 1).'">'.($i + 1).'</a>';
 
250
                    else
 
251
                        $this->maincontent .= '&nbsp;<b>'.($i + 1).'</b>';
 
252

                                    
 
253
                    $i++;
 
254
                }
 
255
            }
 
256

                                    
 
257
            if ($i > ($page + 1))
 
258
                $total = $max * ($page + 1);
 
259
            else
 
260
                $total = $fortunes_list[0];
 
261

                                    
 
262
            if ($fortunes_list[0] == 0)
 
263
                $write = $start;
 
264
            else
 
265
                $write = ($start + 1);
 
266
            
 
267
            $this->maincontent .= '</td>
 
268
            <td style="text-align: right;">'.sprintf(_('%s - %s of %s'), $write, $total, $fortunes_list[0]).'</td>
 
269
            </tr>
 
270
            </tfoot>
 
271
            </table>';
 
272
        }
 
273
        elseif ($this->page[3] == 'show')
 
274
        {
 
275
            if (is_numeric($this->page[4]) && $this->fortunes->load($this->page[4]))
 
276
            {
 
277
                $this->maincontent .= '<h2>'.sprintf(_('Showing fortune #%s'), $this->page[4]).'</h2>';
 
278

                                    
 
279
                $this->maincontent .= '<div class="fortune">
 
280
                <div class="vote">
 
281
                  <a href="jabber/fortunes/vote/'.$this->fortunes->getId().'/bad"><img src="public/images/icons/actions/list-remove.png" alt="-" style="width: 8px;" /></a>
 
282
                  '.$this->fortunes->getVote().'
 
283
                  <a href="jabber/fortunes/vote/'.$this->fortunes->getId().'/good"><img src="public/images/icons/actions/list-add.png" alt="+" style="width: 8px;" /></a>
 
284
                </div>
 
285

                                    
 
286
                <h1><a href="jabber/fortunes/show/'.$this->fortunes->getId().'">'._('Permanent link').'</a></h1>
 
287

                                    
 
288
                <p>
 
289
                '.$this->fortunes->pretty_fortune($this->fortunes->getText()).'
 
290
                </p>';
 
291

                                    
 
292
                if ($this->ct_session->isLogged())
 
293
                    if (is_level($_SESSION['id'], 'administrator', $this->ct_db) || is_affiliation($_SESSION['id'], $this->id, $this->ct_db))
 
294
                        $this->maincontent .= '<ul style="margin-top: 5px;"><li><a href="jabber/fortunes/delete/'.$this->fortunes->getId().'">'._('Delete this fortune').'</a></li></ul>';
 
295

                                    
 
296
                $this->maincontent .= '</div>'; 
 
297

                                    
 
298
            }
 
299
            else
 
300
                exit('Error.');
 
301
        }
 
302
        elseif ($this->page[3] == 'add')
 
303
        {
 
304
            $this->maincontent .= '<h2>'._('Add a fortune').'</h2>';
 
305

                                    
 
306
            if (is_string($this->form_error))
 
307
                $this->maincontent .= '<div class="box error">'.$this->form_error.'</div>';
 
308

                                    
 
309
            $this->maincontent .= '<form action="'.getURLByTags($this->page).'" method="post">
 
310
            <p>
 
311
            <strong>'._('Fortune:').'</strong><br />
 
312
            <textarea name="text" cols="100" rows="10" style="width: 98%;"></textarea>';
 
313

                                    
 
314
            if (!$this->ct_session->isLogged())
 
315
            {
 
316
                $captcha = generateCaptcha();
 
317

                                    
 
318
                $this->maincontent .= '<div style="margin: 20px;width: 280px;border-left: 1px #ccc solid;padding-left: 15px;">
 
319
                <strong>'._('Captcha security:').'</strong><br />
 
320
                '._('In order to check you are not a robot, please answer to that simple question:').'<br />
 
321
                <div class="justify">'.$captcha[0].' + '.$captcha[1].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
322
                <input type="text" style="width:40px;" maxlength="255" name="'.$_SESSION['captcha'].'" value="" />
 
323
                    <input type="text" name="captcha_" value="'.$captcha[2].'" class="captcha" /></div><br />
 
324
                <strong>'._('Nickname:').'</strong><br />
 
325
                <input type="text" style="width: 98%;" maxlength="255" name="nickname" value="';
 
326
                if (!empty($this->form_nickname))
 
327
                    echo htmlspecialchars($this->form_nickname);
 
328
                $this->maincontent .= '" /></div>';
 
329
            }
 
330
            else
 
331
                $this->maincontent .= '<br /><br />';
 
332

                                    
 
333
            $this->maincontent .= '<input type="submit" class="submit" value="'._('Quote it!').'" />
 
334
            </p>
 
335
            </form>';
 
336
        }
 
337
        else
 
338
            exit('Error.');
 
339

                                    
62
340
        return $this->maincontent;
63
341
    }
64
342
}
65
343

                                        

 

Old New Code
268
268

                                        
269
269
        $this->maincontent .= '</select><br /><br />
270
270
        <strong>'._('Code:').'</strong><br />
271
 
        <textarea name="code" cols="100" rows="20" style="width: 95%;">';
 
271
        <textarea name="code" cols="100" rows="20" style="width: 98%;">';
272
272
        
273
273
        if (!empty($this->form_code))
274
274
            $this->maincontent .= htmlspecialchars($this->form_code);
275
275

                                        

 

Old New Code
536
536
                $this->maincontent .= '</ul>
537
537
                </div>';
538
538
            }
539
 
            $this->maincontent .= '<div class="feed" style="background-image: url(\'public/images/feed.png\');">
540
 
            '.sprintf(
541
 
            _('Feed subscription: %s or %s.'), '<a href="rss/project/'.$this->dbname.'/doc/log/'.$this->page_name.'">'._('RSS').'</a>',
542
 
            '<a href="atom/project/'.$this->dbname.'/doc/log/'.$this->page_name.'">'._('Atom').'</a>').'
543
 
            </div>
 
539
            $this->maincontent .= '</div>';
544
540

                                        
545
 
            </div>';
546
 

                                    
547
541
            if (!$this->project_doc->isLatest())
548
542
                $this->maincontent .= '<div style="background: #f0f0f0;border: 1px #8e8e8e solid;width: 60%;margin: 10px;padding: 10px;">
549
543
                '.sprintf(_('Warning: The page you are currently viewing is not the last revision. To view the current version, %s.'), '<a href="project/'.$this->dbname.'/doc/'.$this->page_name.'">'._('click here').'</a>').'
550
544
                </div>';
551
545

                                        
552
 
            $this->maincontent .= $output['content'].'
 
546
            $this->;maincontent .= $output['content'];
553
547

                                        
 
548
            if (!$this->project_doc->isLatest())
 
549
                $this->maincontent .= '<br />
 
550
                <textarea cols="100" rows="20" style="margin-top: 20px;width: 98%;">'.htmlspecialchars($this->project_doc->getText()).'</textarea>';
 
551

                                    
 
552
            $this->maincontent .= '<div style="margin-top: 10px;border-top: 1px #ccc solid;">&nbsp;</div>
 
553
            <div class="feed" style="background-image: url(\'public/images/feed.png\');margin-bottom: 10px;">
 
554
            '.sprintf(
 
555
            _('This page feed: %s or %s.'), '<a href="rss/project/'.$this->dbname.'/doc/log/'.$this->page_name.'">'._('RSS').'</a>',
 
556
            '<a href="atom/project/'.$this->dbname.'/doc/log/'.$this->page_name.'">'._('Atom').'</a>').'
 
557
            </div>
 
558

                                    
 
559
            <div class="feed" style="background-image: url(\'public/images/feed.png\');">
 
560
            '.sprintf(
 
561
            _('Global feed: %s or %s.'), '<a href="rss/project/'.$this->dbname.'/doc">'._('RSS').'</a>',
 
562
            '<a href="atom/project/'.$this->dbname.'/doc">'._('Atom').'</a>').'
 
563
            </div>
554
564
            ';
555
565
        }
556
566

                                        
557
567

                                        

 

Old New Code
80
80
                                'description' => '',
81
81
                                'keywords'    => ''
82
82
                               );
83
 

                                    
84
 
        // Get a timeline
85
 
        $this->timeline = $this->project_timeline->getTimeline($this->id);
86
 

                                    
87
 
        // Translation :)
88
 
        $this->types = array('download' => _('downloads'),
89
 
                             'bugs'     => _('bugs'),
90
 
                             'news'     => _('news'),
91
 
                             'doc'      => _('documentation')
92
 
                            );
93
83
    }
94
84

                                        
95
85
    function showFeed()
96
86
    {
97
87
        global $baseurl;
98
88

                                        
 
89
        // Get a timeline
 
90
        $timeline = $this->project_timeline->getTimeline($this->id, TRUE);
 
91

                                    
99
92
        $feed_array['title'] = sprintf(_('%s timeline'), $this->name);
100
93
        $feed_array['link'] = 'project/'.$this->dbname.'/timeline';
101
94
        $feed_array['description'] = sprintf(_('Latest events for %s.'), $this->name);
102
95

                                        
103
 
        foreach ($this->timeline as $date_)
 
96
        foreach ($timeline as $date_)
104
97
        {
105
98
            $date = $date_[0];
106
99

                                        
144
137
        '<a href="atom/project/'.$this->dbname.'/timeline">'._('Atom').'</a>').'
145
138
        </div>';
146
139

                                        
147
 
        foreach ($this->timeline as $date)
 
140
        // Translation :)
 
141
        $types = array('download' => _('downloads'),
 
142
                       'bugs'     => _('bugs'),
 
143
                       'news'     => _('news'),
 
144
                       'doc'      => _('documentation')
 
145
                      );
 
146

                                    
 
147
        // Get a timeline
 
148
        $timeline = $this->project_timeline->getTimeline($this->id);
 
149

                                    
 
150
        foreach ($timeline as $date)
148
151
        {
149
152
            $this->maincontent .= '<h2>'.i18nDate($date[0], $this->lang).'</h2>
150
153
            <ul class="timeline">'; 
164
167
                    <em>'.$item['time'].'</em>
165
168
                    '.sprintf(_('%s by %s in %s'), '<a href="'.htmlspecialchars($item['link']).'" style="font-weight: bold;color: #000;">'.htmlspecialchars($item['title']).'</a>',
166
169
                                                   $nick,
167
 
                                                   '<a href="/project/'.$this->dbname.'/'.$item['type'].'">'.$this->types[$item['type']].'</a>').
 
170
                                                   '<a href="/project/'.$this->dbname.'/'.$item['type'].'">'.$types[$item['type']].'</a>').
168
171
                    '<br /><span style="color: #8e8e8e;font-style: italic;">'.htmlspecialchars($item['text']).'</span>
169
172
                    </li>';
170
173
                }
171
174

                                        

 

Old New Code
58
58
        $this->jabberid = $this->user->getJid();
59
59
        $this->website = $this->user->getUrl();
60
60
        $this->lang = $this->user->getLang();
 
61
        $this->notif = $this->user->getNotif();
61
62

                                        
62
63
        $this->config = getClass('config', $this->ct_db);
63
64
    }
84
85
            $this->form_name = $this->ct_db->cleanentry($_POST['name'], TRUE);
85
86
            $this->form_surname = $this->ct_db->cleanentry($_POST['surname'], TRUE);
86
87
            $this->form_lang = $this->ct_db->cleanentry($_POST['lang'], TRUE);
 
88
            $this->form_notif = $this->ct_db->cleanentry($_POST['notif'], TRUE);
87
89

                                        
 
90
            // Check if notif is correct
 
91
            if (!in_array($this->form_notif, array('jabber', 'mail', 'none')))
 
92
                exit('Error.');
 
93

                                    
88
94
            // Check if lang prefs is correct
89
95
            if (!in_array($this->form_lang, $this->langlist))
90
96
                exit('Error.');
155
161
                $this->user->setJid($this->form_jabberid);
156
162
                $this->user->setUrl($this->form_website);
157
163
                $this->user->setLang($this->form_lang);
 
164
                $this->user->setNotif($this->form_notif);
158
165
                
159
166
                if ($this->form_avatar != '!nochange!')
160
167
                    $this->user->setAvatar($this->form_avatar);
211
218
        elseif (!empty($this->form_website))
212
219
            $this->maincontent .= htmlspecialchars($this->form_website);
213
220
        $this->maincontent .= '" />
 
221
            <br /><br /><strong>'._('Notification:').'</strong><br />
 
222
            <select name="notif" style="width:250px;">';
 
223

                                    
 
224
        $notifs = array('jabber' => _('Send via Jabber'),
 
225
                        'mail' => _('Send via mail'),
 
226
                        'none' => _('Do not send')
 
227
                       );
 
228

                                    
 
229
        if (!empty($this->form_notif))
 
230
            $_notif = $this->form_notif;
 
231
        elseif (!empty($this->notif))
 
232
            $_notif = $this->notif;
 
233

                                    
 
234
        foreach ($notifs as $key => $value)
 
235
            $this->maincontent .= '<option value='.$key.' '.( ($key == $_notif) ?
 
236
                                  'selected="selected"' :
 
237
                                  '' ).'>'.$value.'</option>';
 
238

                                    
 
239
        $this->maincontent .= '</select>
214
240
            </p></div>
215
241
            <div style="position: relative;width: 250px;"><h3>'._('Personnal information').'</h3><p>
216
242
            <strong>'._('Name:').'</strong><br />
236
262

                                        
237
263
        require($basedir.'/inc/data/i18n.php');
238
264
        foreach ($this->langlist as $key => $value)
239
 
            if ($value == $lg)
 
265
            if (mb_substr($value, 0, 2) == $lg)
240
266
                $this->maincontent .= '<option value="'.$value.'" selected="selected">'.$i18n[$value].'</option>';
241
267
            else
242
268
                $this->maincontent .= '<option value="'.$value.'">'.$i18n[$value].'</option>';
243
269

                                        

 

Old New Code
84
84
            if (!$this->form_error)
85
85
                $this->form_step = 1;
86
86
        }
87
 
        elseif (count($_POST) == 10)
 
87
        elseif (count($_POST) == 11)
88
88
        {
89
89
            $this->form_step = 1;        
90
90
            
97
97
            $this->form_name = $this->ct_db->cleanentry($_POST['name'], TRUE);
98
98
            $this->form_surname = $this->ct_db->cleanentry($_POST['surname'], TRUE);
99
99
            $this->form_lang = $this->ct_db->cleanentry($_POST['lang'], TRUE);
 
100
            $this->form_notif = $this->ct_db->cleanentry($_POST['notif'], TRUE);
100
101

                                        
 
102
            // Check if notif is correct
 
103
            if (!in_array($this->form_notif, array('jabber', 'mail', 'none')))
 
104
                exit('Error.');
 
105

                                    
101
106
            // Check if lang prefs is correct
102
107
            if (!in_array($this->form_lang, $this->langlist))
103
108
                exit('Error.');
259
264
            if (!empty($this->form_website))
260
265
                $this->maincontent .= htmlspecialchars($this->form_website);
261
266
            $this->maincontent .= '" />
 
267
            <br /><br /><strong>'._('Notification:').'</strong><br />
 
268
            <select name="notif" style="width:250px;">';
 
269

                                    
 
270
            $notifs = array('jabber' => _('Send via Jabber'),
 
271
                            'mail' => _('Send via mail'),
 
272
                            'none' => _('Do not send')
 
273
                           );
 
274

                                    
 
275
            foreach ($notifs as $key => $value)
 
276
                $this->maincontent .= '<option value='.$key.' '.( ($key == $this->form_notif) ?
 
277
                                      'selected="selected"' :
 
278
                                      '' ).'>'.$value.'</option>';
 
279

                                    
 
280
            $this->maincontent .= '</select>
262
281
            </p></div>
263
282
            <div style="position: relative;width: 250px;"><h3>'._('Account information').'</h3><p><strong>'._('Nickname:').'</strong><br />
264
283
                <input type="text" style="width:250px;" maxlength="30" name="nickname" class="required-input" value="';
265
284

                                        

 

Old New Code
579
579
#content .fstree .file {
580
580
  background: transparent url('../../public/images/icons/places/file.png') center left no-repeat;
581
581
}
582
 
 
583
582

                                        
 
583
#content .fortune {
 
584
  padding-left: 20px;
 
585
  padding-bottom: 10px;
 
586
  margin-left: 10px;
 
587
  margin-bottom: 20px;
 
588
  border-left: 1px #ccc solid;
 
589
  border-bottom: 1px #ccc solid;  
 
590
}
 
591

                                    
 
592
#content .fortune h1 {
 
593
  font-size: 1.2em;
 
594
}
 
595

                                    
 
596
#content .fortune h1 a {
 
597
  letter-spacing: 0.1em;
 
598
  font-variant: small-caps;
 
599
  color: #ccc; 
 
600
}
 
601

                                    
 
602
#content .fortune .vote {
 
603
  padding-top: 5px;
 
604
  margin-right: 10px;
 
605
  float: right;
 
606
}
 
607

                                    
 
608

                                    
584
609
/* FOOTER */
585
610
#footer {
586
611
  margin-top: 10px;
587
612