Dotclear

source: inc/core/class.dc.rs.extensions.php @ 772:2465bf307591

Revision 772:2465bf307591, 19.5 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

Added new method getURLFor in urlhandler
2 new behaviors :

  • publicGetURLFor
  • publicRegisterURL

All changes are backward compatibles, news plugins will be encouraged
to use new urlhandler method for public URLs generation

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3# This file is part of Dotclear 2.
4#
5# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
6# Licensed under the GPL version 2.0 license.
7# See LICENSE file or
8# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9#
10# -- END LICENSE BLOCK -----------------------------------------
11if (!defined('DC_RC_PATH')) { return; }
12
13/**
14@ingroup DC_CORE
15@brief Dotclear post record helpers.
16
17This class adds new methods to database post results.
18You can call them on every record comming from dcBlog::getPosts and similar
19methods.
20
21@warning You should not give the first argument (usualy $rs) of every described
22function.
23*/
24class rsExtPost
25{
26     /**
27     Returns whether post is editable.
28     
29     @param    rs   Invisible parameter
30     @return   <b>boolean</b>
31     */
32     public static function isEditable($rs)
33     {
34          # If user is admin or contentadmin, true
35          if ($rs->core->auth->check('contentadmin',$rs->core->blog->id)) {
36               return true;
37          }
38         
39          # No user id in result ? false
40          if (!$rs->exists('user_id')) {
41               return false;
42          }
43         
44          # If user is usage and owner of the entrie
45          if ($rs->core->auth->check('usage',$rs->core->blog->id)
46          && $rs->user_id == $rs->core->auth->userID()) {
47               return true;
48          }
49         
50          return false;
51     }
52     
53     /**
54     Returns whether post is deletable
55     
56     @param    rs   Invisible parameter
57     @return   <b>boolean</b>
58     */
59     public static function isDeletable($rs)
60     {
61          # If user is admin, or contentadmin, true
62          if ($rs->core->auth->check('contentadmin',$rs->core->blog->id)) {
63               return true;
64          }
65         
66          # No user id in result ? false
67          if (!$rs->exists('user_id')) {
68               return false;
69          }
70         
71          # If user has delete rights and is owner of the entrie
72          if ($rs->core->auth->check('delete',$rs->core->blog->id)
73          && $rs->user_id == $rs->core->auth->userID()) {
74               return true;
75          }
76         
77          return false;
78     }
79     
80     /**
81     Returns whether post is the first one of its day.
82     
83     @param    rs   Invisible parameter
84     @return   <b>boolean</b>
85     */
86     public static function firstPostOfDay($rs)
87     {
88          if ($rs->isStart()) {
89               return true;
90          }
91         
92          $cdate = date('Ymd',strtotime($rs->post_dt));
93          $rs->movePrev();
94          $ndate = date('Ymd',strtotime($rs->post_dt));
95          $rs->moveNext();
96          return $ndate != $cdate;
97     }
98     
99     /**
100     Returns whether post is the last one of its day.
101     
102     @param    rs   Invisible parameter
103     @return   <b>boolean</b>
104     */
105     public static function lastPostOfDay($rs)
106     {
107          if ($rs->isEnd()) {
108               return true;
109          }
110         
111          $cdate = date('Ymd',strtotime($rs->post_dt));
112          $rs->moveNext();
113          $ndate = date('Ymd',strtotime($rs->post_dt));
114          $rs->movePrev();
115          return $ndate != $cdate;
116     }
117     
118     /**
119     Returns whether comments are enabled on post.
120     
121     @param    rs   Invisible parameter
122     @return   <b>boolean</b>
123     */
124     public static function commentsActive($rs)
125     {
126          return
127          $rs->core->blog->settings->system->allow_comments
128          && $rs->post_open_comment
129          && ($rs->core->blog->settings->system->comments_ttl == 0 ||
130          time()-($rs->core->blog->settings->system->comments_ttl*86400) < $rs->getTS());
131     }
132     
133     /**
134     Returns whether trackbacks are enabled on post.
135     
136     @param    rs   Invisible parameter
137     @return   <b>boolean</b>
138     */
139     public static function trackbacksActive($rs)
140     {
141          return
142          $rs->core->blog->settings->system->allow_trackbacks
143          && $rs->post_open_tb
144          && ($rs->core->blog->settings->system->trackbacks_ttl == 0 ||
145          time()-($rs->core->blog->settings->system->trackbacks_ttl*86400) < $rs->getTS());
146     }
147     
148     /**
149     Returns whether post has at least one comment.
150     
151     @param    rs   Invisible parameter
152     @return   <b>boolean</b>
153     */
154     public static function hasComments($rs)
155     {
156          return $rs->nb_comment > 0;
157     }
158     
159     /**
160     Returns whether post has at least one trackbacks.
161     
162     @return   <b>boolean</b>
163     */
164     public static function hasTrackbacks($rs)
165     {
166          return $rs->nb_trackback > 0;
167     }
168     
169     /**
170     Returns full post URL.
171     
172     @param    rs   Invisible parameter
173     @return   <b>string</b>
174     */
175     public static function getURL($rs)
176     {
177          return $rs->core->blog->url.$rs->core->getPostPublicURL(
178                    $rs->post_type,html::sanitizeURL($rs->post_url)
179               );
180     }
181     
182     /**
183     Returns full post category URL.
184     
185     @param    rs   Invisible parameter
186     @return   <b>string</b>
187     */
188     public static function getCategoryURL($rs)
189     {
190          return $rs->core->url->getURLFor('category',html::sanitizeURL($rs->cat_url));
191     }
192     
193     /**
194     Returns whether post has an excerpt.
195     
196     @param    rs   Invisible parameter
197     @return   <b>boolean</b>
198     */
199     public static function isExtended($rs)
200     {
201          return $rs->post_excerpt_xhtml != '';
202     }
203     
204     /**
205     Returns post timestamp.
206     
207     @param    rs   Invisible parameter
208     @param    type <b>string</b>       (dt|upddt|creadt) defaults to post_dt
209     @return   <b>integer</b>
210     */
211     public static function getTS($rs,$type='')
212     {
213          if ($type == 'upddt') {
214               return strtotime($rs->post_upddt);
215          } elseif ($type == 'creadt') {
216               return strtotime($rs->post_creadt);
217          } else {
218               return strtotime($rs->post_dt);
219          }
220     }
221     
222     /**
223     Returns post date formating according to the ISO 8601 standard.
224     
225     @param    rs   Invisible parameter
226     @param    type <b>string</b>       (dt|upddt|creadt) defaults to post_dt
227     @return   <b>string</b>
228     */
229     public static function getISO8601Date($rs,$type='')
230     {
231          if ($type == 'upddt' || $type == 'creadt') {
232               return dt::iso8601($rs->getTS($type)+dt::getTimeOffset($rs->post_tz),$rs->post_tz);
233          } else {
234               return dt::iso8601($rs->getTS(),$rs->post_tz);
235          }
236     }
237     
238     /**
239     Returns post date formating according to RFC 822.
240     
241     @param    rs   Invisible parameter
242     @param    type <b>string</b>       (dt|upddt|creadt) defaults to post_dt
243     @return   <b>string</b>
244     */
245     public static function getRFC822Date($rs,$type='')
246     {
247          if ($type == 'upddt' || $type == 'creadt') {
248               return dt::rfc822($rs->getTS($type)+dt::getTimeOffset($rs->post_tz),$rs->post_tz);
249          } else {
250               return dt::rfc822($rs->getTS($type),$rs->post_tz);
251          }
252     }
253     
254     /**
255     Returns post date with <var>$format</var> as formatting pattern. If format
256     is empty, uses <var>date_format</var> blog setting.
257     
258     @param    rs   Invisible parameter
259     @param    format    <b>string</b>       Date format pattern
260     @param    type <b>string</b>       (dt|upddt|creadt) defaults to post_dt
261     @return   <b>string</b>
262     */
263     public static function getDate($rs,$format,$type='')
264     {
265          if (!$format) {
266               $format = $rs->core->blog->settings->system->date_format;
267          }
268         
269          if ($type == 'upddt') {
270               return dt::dt2str($format,$rs->post_upddt,$rs->post_tz);
271          } elseif ($type == 'creadt') {
272               return dt::dt2str($format,$rs->post_creadt,$rs->post_tz);
273          } else {
274               return dt::dt2str($format,$rs->post_dt);
275          }
276     }
277     
278     /**
279     Returns post time with <var>$format</var> as formatting pattern. If format
280     is empty, uses <var>time_format</var> blog setting.
281     
282     @param    rs   Invisible parameter
283     @param    format    <b>string</b>       Time format pattern
284     @param    type <b>string</b>       (dt|upddt|creadt) defaults to post_dt
285     @return   <b>string</b>
286     */
287     public static function getTime($rs,$format,$type='')
288     {
289          if (!$format) {
290               $format = $rs->core->blog->settings->system->time_format;
291          }
292         
293          if ($type == 'upddt') {
294               return dt::dt2str($format,$rs->post_upddt,$rs->post_tz);
295          } elseif ($type == 'creadt') {
296               return dt::dt2str($format,$rs->post_creadt,$rs->post_tz);
297          } else {
298               return dt::dt2str($format,$rs->post_dt);
299          }
300     }
301     
302     /**
303     Returns author common name using user_id, user_name, user_firstname and
304     user_displayname fields.
305     
306     @param    rs   Invisible parameter
307     @return   <b>string</b>
308     */
309     public static function getAuthorCN($rs)
310     {
311          return dcUtils::getUserCN($rs->user_id, $rs->user_name,
312          $rs->user_firstname, $rs->user_displayname);
313     }
314     
315     /**
316     Returns author common name with a link if he specified one in its
317     preferences.
318     
319     @param    rs   Invisible parameter
320     @return   <b>string</b>
321     */
322     public static function getAuthorLink($rs)
323     {
324          $res = '%1$s';
325          $url = $rs->user_url;
326          if ($url) {
327               $res = '<a href="%2$s">%1$s</a>';
328          }
329         
330          return sprintf($res,html::escapeHTML($rs->getAuthorCN()),html::escapeHTML($url));
331     }
332     
333     /**
334     Returns author e-mail address. If <var>$encoded</var> is true, "@" sign is
335     replaced by "%40" and "." by "%2e".
336     
337     @param    rs   Invisible parameter
338     @param    encoded   <b>boolean</b>      Encode address.
339     @return   <b>string</b>
340     */
341     public static function getAuthorEmail($rs,$encoded=true)
342     {
343          if ($encoded) {
344               return strtr($rs->user_email,array('@'=>'%40','.'=>'%2e'));
345          }
346          return $rs->user_email;
347     }
348     
349     /**
350     Returns post feed unique ID.
351     
352     @param    rs   Invisible parameter
353     @return   <b>string</b>
354     */
355     public static function getFeedID($rs)
356     {
357          return 'urn:md5:'.md5($rs->core->blog->uid.$rs->post_id);
358         
359          $url = parse_url($rs->core->blog->url);
360          $date_part = date('Y-m-d',strtotime($rs->post_creadt));
361         
362          return 'tag:'.$url['host'].','.$date_part.':'.$rs->post_id;
363     }
364     
365     /**
366     Returns trackback RDF information block in HTML comment.
367     
368     @param    rs   Invisible parameter
369     @return   <b>string</b>
370     */
371     public static function getTrackbackData($rs)
372     {
373          return
374          "<![CDATA[>\n".
375          "<!--[\n".
376          '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n".
377          '  xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n".
378          '  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n".
379          "<rdf:Description\n".
380          '  rdf:about="'.$rs->getURL().'"'."\n".
381          '  dc:identifier="'.$rs->getURL().'"'."\n".
382          '  dc:title="'.htmlspecialchars($rs->post_title,ENT_COMPAT,'UTF-8').'"'."\n".
383          '  trackback:ping="'.$rs->getTrackbackLink().'" />'."\n".
384          "</rdf:RDF>\n".
385          "<!]]><!---->\n";
386     }
387     
388     /**
389     Returns post trackback full URL.
390     
391     @param    rs   Invisible parameter
392     @return   <b>string</b>
393     */
394     public static function getTrackbackLink($rs)
395     {
396          return $rs->core->url->getURLFor('trackback',$rs->post_id);
397     }
398     
399     /**
400     Returns post content. If <var>$absolute_urls</var> is true, appends full
401     blog URL to each relative post URLs.
402     
403     @param    rs   Invisible parameter
404     @param    absolute_urls  <b>boolean</b>      With absolute URLs
405     @return   <b>string</b>
406     */
407     public static function getContent($rs,$absolute_urls=false)
408     {
409          if ($absolute_urls) {
410               return html::absoluteURLs($rs->post_content_xhtml,$rs->getURL());
411          } else {
412               return $rs->post_content_xhtml;
413          }
414     }
415     
416     /**
417     Returns post excerpt. If <var>$absolute_urls</var> is true, appends full
418     blog URL to each relative post URLs.
419     
420     @param    rs   Invisible parameter
421     @param    absolute_urls  <b>boolean</b>      With absolute URLs
422     @return   <b>string</b>
423     */
424     public static function getExcerpt($rs,$absolute_urls=false)
425     {
426          if ($absolute_urls) {
427               return html::absoluteURLs($rs->post_excerpt_xhtml,$rs->getURL());
428          } else {
429               return $rs->post_excerpt_xhtml;
430          }
431     }
432     
433     /**
434     Returns post media count using a subquery.
435     
436     @param    rs   Invisible parameter
437     @return   <b>integer</b>
438     */
439     public static function countMedia($rs)
440     {
441          if (isset($rs->_nb_media[$rs->index()]))
442          {
443               return $rs->_nb_media[$rs->index()];
444          }
445          else
446          {
447               $strReq =
448               'SELECT count(media_id) '.
449               'FROM '.$rs->core->prefix.'post_media '.
450               'WHERE post_id = '.(integer) $rs->post_id.' ';
451               
452               $res = (integer) $rs->core->con->select($strReq)->f(0);
453               $rs->_nb_media[$rs->index()] = $res;
454               return $res;
455          }
456     }
457}
458
459/**
460@ingroup DC_CORE
461@brief Dotclear comment record helpers.
462
463This class adds new methods to database comment results.
464You can call them on every record comming from dcBlog::getComments and similar
465methods.
466
467@warning You should not give the first argument (usualy $rs) of every described
468function.
469*/
470class rsExtComment
471{
472     /**
473     Returns comment date with <var>$format</var> as formatting pattern. If
474     format is empty, uses <var>date_format</var> blog setting.
475     
476     @param    rs   Invisible parameter
477     @param    format    <b>string</b>       Date format pattern
478     @param    type <b>string</b>       (dt|upddt) defaults to comment_dt
479     @return   <b>string</b>
480     */
481     public static function getDate($rs,$format,$type='')
482     {
483          if (!$format) {
484               $format = $rs->core->blog->settings->system->date_format;
485          }
486         
487          if ($type == 'upddt') {
488               return dt::dt2str($format,$rs->comment_upddt,$rs->comment_tz);
489          } else {
490               return dt::dt2str($format,$rs->comment_dt);
491          }
492     }
493     
494     /**
495     Returns comment time with <var>$format</var> as formatting pattern. If
496     format is empty, uses <var>time_format</var> blog setting.
497     
498     @param    rs   Invisible parameter
499     @param    format    <b>string</b>       Date format pattern
500     @param    type <b>string</b>       (dt|upddt) defaults to comment_dt
501     @return   <b>string</b>
502     */
503     public static function getTime($rs,$format,$type='')
504     {
505          if (!$format) {
506               $format = $rs->core->blog->settings->system->time_format;
507          }
508         
509          if ($type == 'upddt') {
510               return dt::dt2str($format,$rs->comment_updt,$rs->comment_tz);
511          } else {
512               return dt::dt2str($format,$rs->comment_dt);
513          }
514     }
515     
516     /**
517     Returns comment timestamp.
518     
519     @param    rs   Invisible parameter
520     @param    type <b>string</b>       (dt|upddt) defaults to comment_dt
521     @return   <b>integer</b>
522     */
523     public static function getTS($rs,$type='')
524     {
525          if ($type == 'upddt') {
526               return strtotime($rs->comment_upddt);
527          } else {
528               return strtotime($rs->comment_dt);
529          }
530     }
531     
532     /**
533     Returns comment date formating according to the ISO 8601 standard.
534     
535     @param    rs   Invisible parameter
536     @param    type <b>string</b>       (dt|upddt) defaults to comment_dt
537     @return   <b>string</b>
538     */
539     public static function getISO8601Date($rs,$type='')
540     {
541          if ($type == 'upddt') {
542               return dt::iso8601($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz);
543          } else {
544               return dt::iso8601($rs->getTS(),$rs->comment_tz);
545          }
546     }
547     
548     /**
549     Returns comment date formating according to RFC 822.
550     
551     @param    rs   Invisible parameter
552     @param    type <b>string</b>       (dt|upddt) defaults to comment_dt
553     @return   <b>string</b>
554     */
555     public static function getRFC822Date($rs,$type='')
556     {
557          if ($type == 'upddt') {
558               return dt::rfc822($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz);
559          } else {
560               return dt::rfc822($rs->getTS(),$rs->comment_tz);
561          }
562     }
563     
564     /**
565     Returns comment content. If <var>$absolute_urls</var> is true, appends full
566     blog URL to each relative post URLs.
567     
568     @param    rs   Invisible parameter
569     @param    absolute_urls  <b>boolean</b>      With absolute URLs
570     @return   <b>string</b>
571     */
572     public static function getContent($rs,$absolute_urls=false)
573     {
574          $res = $rs->comment_content;
575         
576          if ($rs->core->blog->settings->system->comments_nofollow) {
577               $res = preg_replace_callback('#<a(.*?href=".*?".*?)>#ms',array('self','noFollowURL'),$res);
578          }
579         
580          if ($absolute_urls) {
581               $res = html::absoluteURLs($res,$rs->getPostURL());
582          }
583         
584          return $res;
585     }
586     
587     private static function noFollowURL($m)
588     {
589          if (preg_match('/rel="nofollow"/',$m[1])) {
590               return $m[0];
591          }
592         
593          return '<a'.$m[1].' rel="nofollow">';
594     }
595     
596     /**
597     Returns comment author link to his website if he specified one.
598     
599     @param    rs   Invisible parameter
600     @return   <b>string</b>
601     */
602     public static function getAuthorURL($rs)
603     {
604          if (trim($rs->comment_site)) {
605               return trim($rs->comment_site);
606          }
607     }
608     
609     /**
610     Returns comment post full URL.
611     
612     @param    rs   Invisible parameter
613     @return   <b>string</b>
614     */
615     public static function getPostURL($rs)
616     {
617          return $rs->core->blog->url.$rs->core->getPostPublicURL(
618                    $rs->post_type,html::sanitizeURL($rs->post_url)
619               );
620     }
621     
622     /**
623     Returns comment author name in a link to his website if he specified one.
624     
625     @param    rs   Invisible parameter
626     @return   <b>string</b>
627     */
628     public static function getAuthorLink($rs)
629     {
630          $res = '%1$s';
631          $url = $rs->getAuthorURL();
632          if ($url) {
633               $res = '<a href="%2$s"%3$s>%1$s</a>';
634          }
635         
636          $nofollow = '';
637          if ($rs->core->blog->settings->system->comments_nofollow) {
638               $nofollow = ' rel="nofollow"';
639          }
640         
641          return sprintf($res,html::escapeHTML($rs->comment_author),html::escapeHTML($url),$nofollow);
642     }
643     
644     /**
645     Returns comment author e-mail address. If <var>$encoded</var> is true,
646     "@" sign is replaced by "%40" and "." by "%2e".
647     
648     @param    rs   Invisible parameter
649     @param    encoded   <b>boolean</b>      Encode address.
650     @return   <b>string</b>
651     */
652     public static function getEmail($rs,$encoded=true)
653     {
654          if ($encoded) {
655               return strtr($rs->comment_email,array('@'=>'%40','.'=>'%2e'));
656          }
657          return $rs->comment_email;
658     }
659     
660     /**
661     Returns trackback site title if comment is a trackback.
662     
663     @param    rs   Invisible parameter
664     @return   <b>string</b>
665     */
666     public static function getTrackbackTitle($rs)
667     {
668          if ($rs->comment_trackback == 1 &&
669          preg_match('|<p><strong>(.*?)</strong></p>|msU',$rs->comment_content,
670          $match)) {
671               return html::decodeEntities($match[1]);
672          }
673     }
674     
675     /**
676     Returns trackback content if comment is a trackback.
677     
678     @param    rs   Invisible parameter
679     @return   <b>string</b>
680     */
681     public static function getTrackbackContent($rs)
682     {
683          if ($rs->comment_trackback == 1) {
684               return preg_replace('|<p><strong>.*?</strong></p>|msU','',
685               $rs->comment_content);
686          }
687     }
688     
689     /**
690     Returns comment feed unique ID.
691     
692     @param    rs   Invisible parameter
693     @return   <b>string</b>
694     */
695     public static function getFeedID($rs)
696     {
697          return 'urn:md5:'.md5($rs->core->blog->uid.$rs->comment_id);
698         
699          $url = parse_url($rs->core->blog->url);
700          $date_part = date('Y-m-d',strtotime($rs->comment_dt));
701         
702          return 'tag:'.$url['host'].','.$date_part.':'.$rs->comment_id;
703     }
704     
705     /**
706     Returns whether comment is from the post author.
707     
708     @param    rs   Invisible parameter
709     @return   <b>boolean</b>
710     */
711     public static function isMe($rs)
712     {
713          return
714          $rs->comment_email && $rs->comment_site &&
715          $rs->comment_email == $rs->user_email &&
716          $rs->comment_site == $rs->user_url;
717     }
718}
719
720/**
721@ingroup DC_CORE
722@brief Dotclear dates record helpers.
723
724This class adds new methods to database dates results.
725You can call them on every record comming from dcBlog::getDates.
726
727@warning You should not give the first argument (usualy $rs) of every described
728function.
729*/
730class rsExtDates
731{
732     /**
733     @param    rs   Invisible parameter
734     @return   <b>integer</b>      Date timestamp
735     */
736     public static function ts($rs)
737     {
738          return strtotime($rs->dt);
739     }
740     
741     /**
742     @param    rs   Invisible parameter
743     @return   <b>string</b>       Date year
744     */
745     public static function year($rs)
746     {
747          return date('Y',strtotime($rs->dt));
748     }
749     
750     /**
751     @param    rs   Invisible parameter
752     @return   <b>string</b>       Date month
753     */
754     public static function month($rs)
755     {
756          return date('m',strtotime($rs->dt));
757     }
758     
759     /**
760     @param    rs   Invisible parameter
761     @return   <b>integer</b>      Date day
762     */
763     public static function day($rs)
764     {
765          return date('d',strtotime($rs->dt));
766     }
767     
768     /**
769     Returns date month archive full URL.
770     
771     @param    rs   Invisible parameter
772     @param    core      <b>dcCore</b>       dcCore instance
773     @return   <b>integer</b>
774     */
775     public static function url($rs,$core)
776     {
777          $url = date('Y/m',strtotime($rs->dt));
778         
779          return $core->url->getURLFor('archive',$url);
780     }
781     
782     /**
783     Returns whether date is the first of year.
784     
785     @param    rs   Invisible parameter
786     @return   <b>boolean</b>
787     */
788     public static function yearHeader($rs)
789     {
790          if ($rs->isStart()) {
791               return true;
792          }
793         
794          $y = $rs->year();
795          $rs->movePrev();
796          $py = $rs->year();
797          $rs->moveNext();
798         
799          return $y != $py;
800     }
801     
802     /**
803     Returns whether date is the last of year.
804     
805     @param    rs   Invisible parameter
806     @return   <b>boolean</b>
807     */
808     public static function yearFooter($rs)
809     {
810          if ($rs->isEnd()) {
811               return true;
812          }
813         
814          $y = $rs->year();
815          if ($rs->moveNext()) {
816               $ny = $rs->year();
817               $rs->movePrev();
818               return $y != $ny;
819          }
820          return false;
821         
822     }
823}
824
825/**
826@ingroup DC_CORE
827@brief Dotclear dates record helpers.
828
829This class adds new methods to database dates results.
830You can call them on every record comming from dcAuth::checkUser and
831dcCore::getUsers.
832
833@warning You should not give the first argument (usualy $rs) of every described
834function.
835*/
836class rsExtUser
837{
838     /**
839     Returns a user option.
840     
841     @param    rs   Invisible parameter
842     @param    name      <b>string</b>       Option name
843     @return   <b>string</b>
844     */
845     public static function option($rs,$name)
846     {
847          $options = self::options($rs);
848         
849          if (isset($options[$name])) {
850               return $options[$name];
851          }
852          return null;
853     }
854     
855     /**
856     Returns all user options.
857     
858     @param    rs   Invisible parameter
859     @return   <b>array</b>
860     */
861     public static function options($rs)
862     {
863          $options = @unserialize($rs->user_options);
864          if (is_array($options)) {
865               return $options;
866          }
867          return array();
868     }
869}
870?>
Note: See TracBrowser for help on using the repository browser.

Sites map