Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezarticle.php 9874 2003-07-22 11:14:49Z br $
5 //
6 // Definition of eZArticle class
7 //
8 // Created on: <18-Oct-2000 13:50:24 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
61 // include_once( "classes/ezdb.php" );
62 // include_once( "classes/ezdatetime.php" );
63 // include_once( "classes/eztemplate.php" );
64 // include_once( "classes/eztexttool.php" );
65 // include_once( "ezmail/classes/ezmail.php" );
66 // include_once( "ezuser/classes/ezuser.php" );
67 // include_once( "ezuser/classes/ezusergroup.php" );
68 // include_once( "ezuser/classes/ezauthor.php" );
69
70 // include_once( "ezimagecatalogue/classes/ezimage.php" );
71 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
72
73 // include_once( "ezmediacatalogue/classes/ezmedia.php" );
74
75 // include_once( "ezforum/classes/ezforum.php" );
76 // include_once( "ezarticle/classes/ezarticlecategory.php" );
77 // include_once( "ezarticle/classes/ezarticlecategory.php" );
78 // include_once( "ezarticle/classes/ezarticleattribute.php" );
79 // include_once( "ezarticle/classes/ezarticletype.php" );
80
81 class eZArticle
82 {
89 function __construct( $id="" )
90 {
91 // default value
92 $this->IsPublished = "0";
93 $this->StartDate = 0;
94 $this->StopDate = 0;
95 //$this->Discuss = 0;
96 $this->TopicID = 0;
97
98 $this->PublishedOverride = 0;
99
100 if ( is_array( $id ) )
101 {
102 $this->fill( $id );
103 }
104 else if ( $id != "" )
105 {
106 $this->ID = $id;
107 $this->get( $this->ID );
108 }
109 }
110
114 function store()
115 {
116 $db =& eZDB::globalDatabase();
117 $db->begin();
118
119 $name = $db->escapeString( $this->Name );
120 $contents = $db->escapeString( $this->Contents );
121 $authortext = $db->escapeString( $this->AuthorText );
122 $authoremail = $db->escapeString( $this->AuthorEmail );
123 $linktext = $db->escapeString( $this->LinkText );
124 $keywords = $db->escapeString( $this->Keywords );
125 $importID = $db->escapeString( $this->ImportID );
126
127 if ( is_object( $this->StartDate ) and $this->StartDate->isValid() )
128 $startDate = $this->StartDate->timeStamp();
129 else
130 $startDate = $this->StartDate;
131
132 if ( is_object( $this->StopDate ) and $this->StopDate->isValid() )
133 $stopDate = $this->StopDate->timeStamp();
134 else
135 $stopDate = $this->StopDate;
136
137 if ( !isset( $this->ID ) )
138 {
139 $db->lock( "eZArticle_Article" );
140
141 $nextID = $db->nextID( "eZArticle_Article", "ID" );
142
143 $timeStamp =& (new eZDateTime())->timeStamp( true );
144
145 if ( $this->PublishedOverride != 0 )
146 $published = $this->PublishedOverride;
147 else
148 $published = $timeStamp;
149
150
151 // fix for informix blob field
152 $contentsStr = "'$contents'";
153
154 if ( $db->isA() == "informix" )
155 {
156 $textid = ifx_create_blob( 0, 0, $this->Contents );
157
158 // $textid = ifx_create_char( $contents );
159 $blobIDArray[] = $textid;
160 $contentsStr = "?";
161 $db->setBlobArray( $blobIDArray );
162
163 }
164
165 $ret = $db->query( "INSERT INTO eZArticle_Article
166 ( ID,
167 Name,
168 Contents,
169 AuthorID,
170 LinkText,
171 PageCount,
172 IsPublished,
173 Keywords,
174 Discuss,
175 ContentsWriterID,
176 TopicID,
177 StartDate,
178 StopDate,
179 Modified,
180 Published,
181 Created,
182 ImportID )
183 VALUES
184 ( '$nextID',
185 '$name',
186 $contentsStr,
187 '$this->AuthorID',
188 '$linktext',
189 '$this->PageCount',
190 '$this->IsPublished',
191 '$keywords',
192 '$this->Discuss',
193 '$this->ContentsWriterID',
194 '$this->TopicID',
195 '$startDate',
196 '$stopDate',
197 '$timeStamp',
198 '$published',
199 '$timeStamp',
200 '$importID' )
201 " );
202
203 $this->ID = $nextID;
204 }
205 else
206 {
207
208 // fix for informix blob field
209 $contentsStr = "Contents='$contents',";
210
211 if ( $db->isA() == "informix" )
212 {
213 ifx_textasvarchar(0);
214 $db->array_query( $res, "SELECT ID, Contents FROM eZArticle_Article WHERE ID='$this->ID'" );
215
216
217 $bid = $res[0][$db->fieldName("Contents")];
218 // fetch the blob id
219 $res = ifx_update_blob( $bid, $this->Contents );
220
221 if ( !$res )
222 {
223 print( "Error updating informix text blob" );
224 die();
225 }
226
227 $blobIDArray[] = $bid;
228 $db->setBlobArray( $blobIDArray );
229
230 $contentsStr = "Contents=?,";
231 ifx_textasvarchar(1);
232 }
233
234
235 $db->array_query( $res, "SELECT ID FROM eZArticle_Article WHERE IsPublished='0' AND ID='$this->ID'" );
236
237 $timeStamp =& (new eZDateTime())->timeStamp( true );
238
239 if ( $this->PublishedOverride != 0 )
240 $published = $this->PublishedOverride;
241 else
242 $published = $timeStamp;
243
244 if ( ( count( $res ) > 0 ) && ( $this->IsPublished == "1" ) )
245 {
246 $queryText = "UPDATE eZArticle_Article SET
247 Name='$name',
248 $contentsStr
249 LinkText='$linktext',
250 PageCount='$this->PageCount',
251 AuthorID='$this->AuthorID',
252 IsPublished='$this->IsPublished',
253 Keywords='$keywords',
254 Discuss='$this->Discuss',
255 ContentsWriterID='$this->ContentsWriterID',
256 TopicID='$this->TopicID',
257 StartDate='$startDate',
258 StopDate='$stopDate',
259 Published='$published',
260 Modified='$timeStamp',
261 ImportID='$importID'
262 WHERE ID='$this->ID'
263 ";
264
265 $ret = $db->query( $queryText );
266 }
267 else
268 {
269 if ( $this->PublishedOverride != 0 )
270 {
271 $published = $this->PublishedOverride;
272 }
273 else
274 {
275 if( $this->Published != '' )
276 $published = $this->Published;
277 else
278 $published = $timeStamp;
279 }
280 $queryText = "UPDATE eZArticle_Article SET
281 Name='$name',
282 $contentsStr
283 LinkText='$linktext',
284 PageCount='$this->PageCount',
285 AuthorID='$this->AuthorID',
286 IsPublished='$this->IsPublished',
287 Keywords='$keywords',
288 Discuss='$this->Discuss',
289 ContentsWriterID='$this->ContentsWriterID',
290 TopicID='$this->TopicID',
291 Published='$published',
292 StartDate='$startDate',
293 StopDate='$stopDate',
294 Modified='$timeStamp',
295 ImportID='$importID'
296 WHERE ID='$this->ID'
297 ";
298
299 $ret = $db->query( $queryText );
300 }
301 }
302
303 $db->unlock();
304
305 if ( $ret == false )
306 $db->rollback( );
307 else
308 $db->commit();
309
310 // index this article
311 $this->createIndex();
312
313 return true;
314 }
315
319 function get( $id="" )
320 {
321 $db =& eZDB::globalDatabase();
322 $ret = false;
323
324 if ( $id != "" )
325 {
326 $db->array_query( $article_array, "SELECT * FROM eZArticle_Article WHERE ID='$id'" );
327 if ( count( $article_array ) > 1 )
328 {
329 die( "Error: Article's with the same ID was found in the database. This shouldent happen." );
330 }
331 else if ( count( $article_array ) == 1 )
332 {
333 $this->fill( $article_array[0] );
334 $ret = true;
335 }
336 }
337 return $ret;
338 }
339
340 function fill( $article_array )
341 {
342 $db =& eZDB::globalDatabase();
343 $this->ID =& $article_array[$db->fieldName("ID")];
344 $this->Name =& $article_array[$db->fieldName("Name")];
345 $this->Contents =& $article_array[$db->fieldName("Contents")];
346 $this->AuthorText =& $article_array[$db->fieldName("AuthorText")];
347 $this->AuthorEmail =& $article_array[$db->fieldName("AuthorEmail")];
348 $this->AuthorID =& $article_array[$db->fieldName("AuthorID")];
349 $this->LinkText =& $article_array[$db->fieldName("LinkText")];
350 $this->Modified =& $article_array[$db->fieldName("Modified")];
351 $this->Created =& $article_array[$db->fieldName("Created")];
352 $this->Published =& $article_array[$db->fieldName("Published")];
353 $this->PageCount =& $article_array[$db->fieldName("PageCount")];
354 $this->IsPublished =& $article_array[$db->fieldName("IsPublished")];
355 $this->Keywords =& $article_array[$db->fieldName("Keywords")];
356 $this->Discuss =& $article_array[$db->fieldName("Discuss")];
357 $this->ContentsWriterID =& $article_array[$db->fieldName("ContentsWriterID")];
358 $this->TopicID =& $article_array[$db->fieldName("TopicID")];
359 $this->StartDate =& $article_array[$db->fieldName("StartDate")];
360 $this->StopDate =& $article_array[$db->fieldName("StopDate")];
361 $this->ImportID =& $article_array[$db->fieldName("ImportID")];
362 }
363
370 static public function &getByName( $name )
371 {
372 $db =& eZDB::globalDatabase();
373
374 $topic = new eZArticle();
375
376 $name = $db->escapeString( $name );
377
378 if( $name != "" )
379 {
380 $db->array_query( $author_array, "SELECT * FROM eZArticle_Article WHERE Name='$name'" );
381
382 if( count( $author_array ) == 1 )
383 {
384 $topic = new eZArticle( $author_array[0] );
385 }
386 }
387
388 return $topic;
389 }
396 static public function &getByImportID( $name )
397 {
398 $db =& eZDB::globalDatabase();
399
400 $topic = new eZArticle();
401
402 $name = $db->escapeString( $name );
403
404 if( $name != "" )
405 {
406 $db->array_query( $author_array, "SELECT * FROM eZArticle_Article WHERE ImportID='$name'" );
407
408 if( count( $author_array ) == 1 )
409 {
410 $topic = new eZArticle( $author_array[0] );
411 }
412 }
413
414 return $topic;
415 }
416
417
421 function delete()
422 {
423 $db =& eZDB::globalDatabase();
424
425 if ( isset( $this->ID ) )
426 {
427 $imageList =& $this->images();
428 $fileList =& $this->files();
429 foreach( $imageList as $image )
430 {
431 // print_r( $image );
432
433 // $image->delete();
434 }
435 foreach( $fileList as $file )
436 {
437 // $file->delete();
438 }
439 $db->begin();
440
441 $forum = $this->forum();
442 $forum->delete();
443 $res = array();
444
445 $res[] = $db->query( "DELETE FROM eZArticle_ArticleCategoryLink WHERE ArticleID='$this->ID'" );
446 $res[] = $db->query( "DELETE FROM eZArticle_ArticleCategoryDefinition WHERE ArticleID='$this->ID'" );
447 $res[] = $db->query( "DELETE FROM eZArticle_ArticleImageLink WHERE ArticleID='$this->ID'" );
448 $res[] = $db->query( "DELETE FROM eZArticle_ArticleImageDefinition WHERE ArticleID='$this->ID'" );
449 $res[] = $db->query( "DELETE FROM eZArticle_ArticlePermission WHERE ObjectID='$this->ID'" );
450 $res[] = $db->query( "DELETE FROM eZArticle_Article WHERE ID='$this->ID'" );
451 $res[] = $db->query( "DELETE FROM eZArticle_AttributeValue WHERE ArticleID='$this->ID'" );
452 $res[] = $db->query( "DELETE FROM eZArticle_ArticleForumLink WHERE ArticleID='$this->ID'" );
453
454 if ( in_array( false, $res ) )
455 $db->rollback( );
456 else
457 $db->commit();
458
459 }
460
461 return true;
462 }
463
467 function id()
468 {
469 return $this->ID;
470 }
471
475 function name( $asHTML = true )
476 {
477 if( $this->Name != '' && $asHTML == true )
478 {
479 $name = stripslashes($this->Name);
480 return eZTextTool::fixhtmlentities( htmlspecialchars( $name ) );
481 }
482 return $this->Name;
483 }
484
488 function &importID( )
489 {
490 return $this->ImportID;
491 }
492
498 function &contents()
499 {
500 $db =& eZDB::globalDatabase();
501
502 return $this->Contents;
503 }
504
508 function &authorText( $asHTML = true )
509 {
510 $author = new eZAuthor( $this->ContentsWriterID );
511
512 if( $asHTML == true )
513 return eZTextTool::fixhtmlentities( htmlspecialchars( $author->name() ) );
514 return $author->name();
515 }
516
520 function &authorEmail( $asHTML = true )
521 {
522 $author = new eZAuthor( $this->ContentsWriterID );
523
524 if( $asHTML == true )
525 return htmlspecialchars( $author->email() );
526 return $author->email();
527 }
528
529
533 function &linkText( $asHTML = true )
534 {
535 if( $asHTML )
536 return eZTextTool::fixhtmlentities( htmlspecialchars( $this->LinkText ) );
537 return $this->LinkText;
538 }
539
543 function &author( $as_object = true )
544 {
545 if( $as_object )
546 $author = new eZUser( $this->AuthorID );
547 else
548 $author = $this->AuthorID;
549 return $author;
550 }
551
555 function &pageCount()
556 {
557 return substr_count( $this->Contents, "<page>" );
558 }
559
565 function &created()
566 {
567 $dateTime = new eZDateTime();
568 $dateTime->setTimeStamp( $this->Created );
569
570 return $dateTime;
571 }
572
578 function &modified()
579 {
580 $dateTime = new eZDateTime();
581 $dateTime->setTimeStamp( $this->Modified );
582
583 return $dateTime;
584 }
585
589 function keywords( )
590 {
591 $this->Keywords = stripslashes($this->Keywords);
592 return $this->Keywords;
593 }
594
598 function discuss( )
599 {
600 $ret = false;
601 if ( $this->Discuss == 1 )
602 {
603 $ret = true;
604 }
605 return $ret;
606 }
607
608
614 function &published()
615 {
616 $dateTime = new eZDateTime();
617 $dateTime->setTimeStamp( $this->Published );
618
619 return $dateTime;
620 }
621
625 function isPublished()
626 {
627 $ret = false;
628 if ( $this->IsPublished == "1" )
629 {
630 $ret = 1;
631 }
632 elseif ( $this->IsPublished == "2" )
633 {
634 $ret = 2;
635 }
636 return $ret;
637 }
638
642 function &startDate( $as_object=true )
643 {
644 if ( $as_object )
645 {
646 $ret = new eZDateTime();
647 $ret->setTimeStamp( $this->StartDate );
648 return $ret;
649 }
650 else
651 return $this->StartDate;
652 }
653
657 function &stopDate( $as_object=true )
658 {
659 if ( $as_object )
660 {
661 $ret = new eZDateTime();
662 $ret->setTimeStamp( $this->StopDate );
663 return $ret;
664 }
665 else
666 return $this->StopDate;
667 }
668
672 function setName( $value )
673 {
674 $this->Name = $value;
675 }
676
680 function setImportID( $value )
681 {
682 $this->ImportID = $value;
683 }
684
688 function setContents( $value )
689 {
690 $this->Contents = $value;
691 }
692
696 function setAuthorText( $value )
697 {
698 $this->AuthorText = $value;
699 }
700
704 function setAuthorEmail( $value )
705 {
706 $this->AuthorEmail = $value;
707 }
708
712 function setLinkText( $value )
713 {
714 $this->LinkText = $value;
715 }
716
720 function setAuthor( $user )
721 {
722 if ( is_a( $user, "eZUser" ) )
723 {
724 $this->AuthorID = $user->id();
725 }
726 }
727
731 function setPageCount( $value )
732 {
733 $this->PageCount = $value;
734 }
735
739 function setKeywords( $keywords )
740 {
741 // replace newlines with space
742 $keywords = str_replace ("\n\r", " ", $keywords );
743 $keywords = str_replace ("\r\n", " ", $keywords );
744 $keywords = str_replace ("\n", " ", $keywords );
745 $keywords = str_replace ("\r", " ", $keywords );
746 $this->Keywords = $keywords;
747 }
748
753 function createIndex()
754 {
755 // generate keywords
756 $tmpContents = $this->Contents;
757
758 $tmpContents = str_replace ("</intro>", " ", $tmpContents );
759 $tmpContents = str_replace ("</page>", " ", $tmpContents );
760
761 $contents = strtolower( strip_tags( $tmpContents ) ) . " " . $this->Name;
762 $contents = str_replace ("\n", "", $contents );
763 $contents = str_replace ("\r", "", $contents );
764 $contents = str_replace ("(", " ", $contents );
765 $contents = str_replace (")", " ", $contents );
766 $contents = str_replace (",", " ", $contents );
767 $contents = str_replace (".", " ", $contents );
768 $contents = str_replace ("/", " ", $contents );
769 $contents = str_replace ("-", " ", $contents );
770 $contents = str_replace ("_", " ", $contents );
771 $contents = str_replace ("\"", " ", $contents );
772 $contents = str_replace ("'", " ", $contents );
773 $contents = str_replace (":", " ", $contents );
774 $contents = str_replace ("?", " ", $contents );
775 $contents = str_replace ("!", " ", $contents );
776 $contents = str_replace ("\"", " ", $contents );
777 $contents = str_replace ("|", " ", $contents );
778 $contents = str_replace ("qdom", " ", $contents );
779 $contents = str_replace ("tech", " ", $contents );
780
781 // strip &quot; combinations
782 $contents = preg_replace("(&.+?;)", " ", $contents );
783
784 // strip multiple whitespaces
785 $contents = preg_replace("(\s+)", " ", $contents );
786
787 $contents_array =& preg_split( "/ /", $contents );
788 $contents_array =& array_merge( $contents_array, $this->manualKeywords( true ) );
789
790 $totalWordCount = count( $contents_array );
791 $wordCount = array_count_values( $contents_array );
792
793 $contents_array = array_unique( $contents_array );
794
795 $keywords = "";
796 foreach ( $contents_array as $word )
797 {
798 if ( strlen( $word ) >= 2 )
799 {
800 $keywords .= $word . " ";
801 }
802 }
803
804 $this->Keywords = $keywords;
805
806 $db =& eZDB::globalDatabase();
807 $ret = array();
808
809 $ret[] = $db->query( "DELETE FROM eZArticle_ArticleWordLink WHERE ArticleID='$this->ID'" );
810
811 // get total number of articles
812 $db->array_query( $article_array, "SELECT COUNT(*) AS Count FROM eZArticle_Article" );
813 $articleCount = $article_array[0][$db->fieldName( "Count" )];
814
815 $db->begin( );
816
817 foreach ( $contents_array as $word )
818 {
819 if ( strlen( $word ) >= 2 )
820 {
821 $indexWord = $word;
822
823 $indexWord = $db->escapeString( $indexWord );
824
825
826 // find the frequency
827 $count = $wordCount[$indexWord];
828
829 $freq = ( $count / $totalWordCount );
830
831 $query = "SELECT ID FROM eZArticle_Word
832 WHERE Word='$indexWord'";
833
834 $db->array_query( $word_array, $query );
835
836
837 if ( count( $word_array ) == 1 )
838 {
839 // word exists create reference
840 $wordID = $word_array[0][$db->fieldName("ID")];
841
842 // number of links to this word
843 $db->array_query( $article_array, "SELECT COUNT(*) AS Count FROM eZArticle_ArticleWordLink WHERE WordID='$wordID'" );
844 $wordUsageCount = $article_array[0][$db->fieldName( "Count" )];
845
846 $wordFreq = ( $wordUsageCount + 1 ) / $articleCount;
847
848 // update word frequency
849 $ret[] = $db->query( "UPDATE eZArticle_Word SET Frequency='$wordFreq' WHERE ID='$wordID'" );
850
851
852 $ret[] = $db->query( "INSERT INTO eZArticle_ArticleWordLink ( ArticleID, WordID, Frequency ) VALUES
853 ( '$this->ID',
854 '$wordID',
855 '$freq' )" );
856 }
857 else
858 {
859 // lock the table
860 $db->lock( "eZArticle_Word" );
861
862 $wordFreq = 1 / $articleCount;
863
864 // new word, create word
865 $nextID = $db->nextID( "eZArticle_Word", "ID" );
866 $ret[] = $db->query( "INSERT INTO eZArticle_Word ( ID, Word, Frequency ) VALUES
867 ( '$nextID',
868 '$indexWord',
869 '$wordFreq' )" );
870 $db->unlock();
871
872 $ret[] = $db->query( "INSERT INTO eZArticle_ArticleWordLink ( ArticleID, WordID, Frequency ) VALUES
873 ( '$this->ID',
874 '$nextID',
875 '$freq' )" );
876
877 }
878 }
879 }
880 eZDB::finish( $ret, $db );
881
882 }
883
887 function setDiscuss( $discuss )
888 {
889 if ( $discuss == true )
890 $this->Discuss = 1;
891 else
892 $this->Discuss = 0;
893 }
894
898 function setManualKeywords( $keywords, $toLower = true )
899 {
900 if ( !is_array( $keywords ) )
901 {
902 $words = explode( ",", $keywords );
903 $keywords = array();
904 foreach( $words as $word )
905 {
906 if( $toLower )
907 {
908 $keyword = strtolower( trim( $word ) );
909 }
910 else
911 {
912 $keyword = trim( $word );
913 }
914 if ( $keyword != "" )
915 $keywords[] = $keyword;
916 }
917 }
918 $db =& eZDB::globalDatabase();
919 $db->query( "DELETE FROM eZArticle_ArticleKeyword WHERE ArticleID='$this->ID' AND Automatic='0'" );
920 foreach( $keywords as $keyword )
921 {
922 $db->begin( );
923
924 $keyword = $db->escapeString( $keyword );
925
926 $db->lock( "eZArticle_ArticleKeyword" );
927
928 $nextID = $db->nextID( "eZArticle_ArticleKeyword", "ID" );
929
930 $res = $db->query( "INSERT INTO eZArticle_ArticleKeyword
931 ( ID,
932 ArticleID,
933 Keyword,
934 Automatic )
935 VALUES
936 ( '$nextID',
937 '$this->ID',
938 '$keyword',
939 '0' )" );
940
941
942 $db->unlock();
943
944
945 // Create first letter cache table
946 $db->array_query( $letter_array, "SELECT SUBSTRING( Keyword from 1 for 1 ) AS Letter
947 FROM eZArticle_ArticleKeyword GROUP BY Letter" );
948
949 $db->lock( "eZArticle_ArticleKeywordFirstLetter" );
950
951 $db->query( "DELETE FROM eZArticle_ArticleKeywordFirstLetter" );
952
953 foreach ( $letter_array as $letter )
954 {
955 $nextID = $db->nextID( "eZArticle_ArticleKeywordFirstLetter", "ID" );
956
957 $letter = strToLower( $letter[$db->fieldName("Letter")] );
958
959 $res = $db->query( "INSERT INTO eZArticle_ArticleKeywordFirstLetter
960 ( ID,
961 Letter )
962 VALUES
963 ( '$nextID',
964 '$letter' )" );
965 }
966
967 $db->unlock();
968
969 if ( $res == false )
970 $db->rollback( );
971 else
972 $db->commit();
973 }
974 }
975
982 static public function &keywordFirstLetters( )
983 {
984 $db =& eZDB::globalDatabase();
985
986 $db->array_query( $letter_array, "SELECT SUBSTRING( Keyword from 1 for 1 ) AS Letter
987 FROM eZArticle_ArticleKeyword GROUP BY Letter ORDER BY Letter" );
988
989 $retArray = array();
990 foreach ( $letter_array as $letter )
991 {
992 $nextID = $db->nextID( "eZArticle_ArticleKeywordFirstLetter", "ID" );
993
994 $letter = strToLower( $letter[$db->fieldName("Letter")] );
995 $retArray[] = $letter;
996 }
997
998 return $retArray;
999 }
1000
1004 function setStartDate( &$date )
1005 {
1006 if ( is_a( $date, "eZDateTime" ) )
1007 {
1008 if ( !( $date->year() == "1970" && $date->month() == "1" && $date->day() == "1" ) )
1009 {
1010 $this->StartDate = $date;
1011
1012 $now = (new eZDateTime())->timeStamp( true );
1013 $startDate = $date->timeStamp();
1014
1015 if ( ( $startDate < $now ) and ( $date->year() != "1970" ) )
1016 {
1017 $this->PublishedOverride = $startDate;
1018 $this->IsPublished = 1;
1019 $this->StartDate = 0;
1020 }
1021 }
1022 }
1023 else
1024 $this->StartDate = 0;
1025
1026 }
1027
1031 function setStopDate( &$date )
1032 {
1033 if ( is_a ( $date, "eZDateTime" ) )
1034 $this->StopDate = $date;
1035 else
1036 $this->StopDate = 0;
1037 }
1038
1043 function &manualKeywords( $as_array = false )
1044 {
1045 $db =& eZDB::globalDatabase();
1046 $db->array_query($keywords, "SELECT Keyword FROM eZArticle_ArticleKeyword
1047 WHERE ArticleID='$this->ID' AND Automatic='0'" );
1048 $ret = array();
1049 foreach( $keywords as $keyword )
1050 {
1051 $ret[] = $keyword[$db->fieldName("Keyword")];
1052 }
1053 if ( !$as_array )
1054 $ret = implode( ", ", $ret );
1055 return $ret;
1056 }
1057
1064 static public function &manualKeywordIndex( $firstLetter = false )
1065 {
1066 $user =& eZUser::currentUser();
1067 $currentUserSQL = "";
1068 $groupSQL = "";
1069 if ( $user )
1070 {
1071 $groups =& $user->groups( false );
1072
1073 $i = 0;
1074 foreach ( $groups as $group )
1075 {
1076 if ( $i == 0 )
1077 $groupSQL .= "Permission.GroupID=$group OR";
1078 else
1079 $groupSQL .= " Permission.GroupID=$group OR";
1080
1081 $i++;
1082 }
1083 $currentUserID = $user->id();
1084 $currentUserSQL = "Article.AuthorID=$currentUserID OR";
1085 }
1086 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL Permission.GroupID='-1' ) AND Permission.ReadPermission='1') ) AND";
1087
1088 $firstLetterSQL = "";
1089 if ( $firstLetter != false )
1090 {
1091 $firstLetterSQL = " HAVING Letter='$firstLetter' ";
1092 }
1093 $db =& eZDB::globalDatabase();
1094 $db->array_query( $keywords, "SELECT ArtKey.Keyword AS Keyword, SUBSTRING( ArtKey.Keyword from 1 for 1 ) AS Letter
1095 FROM eZArticle_ArticleCategoryLink as Link,
1096 eZArticle_ArticlePermission AS Permission,
1097 eZArticle_Category AS Category,
1098 eZArticle_Article AS Article LEFT JOIN eZArticle_ArticleKeyword AS ArtKey ON
1099 Article.ID=ArtKey.ArticleID
1100 WHERE (
1101 ( $loggedInSQL ($groupSQL Permission.GroupID='-1') AND Permission.ReadPermission='1' )
1102 )
1103 AND Article.IsPublished = '1'
1104 AND Permission.ObjectID=Article.ID
1105 AND Link.ArticleID=Article.ID
1106 AND Category.ID=Link.CategoryID
1107 AND Category.ExcludeFromSearch = '0'
1108 AND ArtKey.Keyword is not NULL
1109 GROUP BY Keyword $firstLetterSQL ORDER BY Keyword", 0, -1, "Keyword" );
1110 return $keywords;
1111 }
1112
1116 function setContentsWriter( $author )
1117 {
1118 if ( is_numeric( $author ) )
1119 $this->ContentsWriterID = $author;
1120 else
1121 $this->ContentsWriterID = $author->id();
1122 }
1123
1127 function contentsWriter( $returnObject = true )
1128 {
1129 if ( $returnObject )
1130 return new eZAuthor( $this->ContentsWriterID );
1131 else
1132 return $this->ContentsWriterID;
1133 }
1134
1135
1139 function setTopic( $topic )
1140 {
1141 $this->TopicID = is_numeric( $topic ) ? $topic : $topic->id();
1142 }
1143
1149 function topic( $as_object = true )
1150 {
1151 // include_once( "ezarticle/classes/eztopic.php" );
1152 return $as_object ? new eZTopic( $this->TopicID ) : $this->TopicID;
1153 }
1154
1159 static public function &searchByShortContent( $short_content, $keywords, $offset = 0, $max = -1, $as_object = true )
1160 {
1161 $db =& eZDB::globalDatabase();
1162 $content_sql = "";
1163 $keyword_sql = "";
1164 if ( count( $keywords ) > 0 )
1165 {
1166 foreach( $keywords as $keyword )
1167 {
1168 if ( $keyword_sql != "" )
1169 $keyword_sql .= " OR ";
1170 $keyword_sql .= "ArtKey.Keyword='$keyword'";
1171 }
1172 if ( $content_sql != "" )
1173 $keyword_sql = "AND ( $keyword_sql )";
1174 }
1175 $conditions = "";
1176 if ( $content_sql != "" or $keyword_sql != "" )
1177 {
1178 $conditions = "AND $content_sql $keyword_sql";
1179 }
1180 $limit_sql = "";
1181 if ( !is_bool( $offset ) and $max > 0 )
1182 {
1183 $limit_sql = "LIMIT $offset, $max";
1184 }
1185
1186 $user =& eZUser::currentUser();
1187 $currentUserSQL = "";
1188 $groupSQL = "";
1189 if ( $user )
1190 {
1191 $groups = $user->groups( false );
1192
1193 $i = 0;
1194 foreach ( $groups as $group )
1195 {
1196 if ( $i == 0 )
1197 $groupSQL .= "Permission.GroupID=$group OR";
1198 else
1199 $groupSQL .= " Permission.GroupID=$group OR";
1200
1201 $i++;
1202 }
1203 $currentUserID = $user->id();
1204 $currentUserSQL = "Article.AuthorID=$currentUserID OR";
1205 }
1206 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL Permission.GroupID='-1' ) AND Permission.ReadPermission='1') ) AND";
1207
1208 $select_sql = "";
1209 if ( is_bool( $offset ) )
1210 {
1211 $select_sql = "count( DISTINCT Article.ID ) as ArticleCount";
1212 }
1213 else
1214 {
1215 $select_sql = "DISTINCT Article.ID as ArticleID";
1216 }
1217 $sql = "SELECT $select_sql, Article.Name
1218 FROM eZArticle_ArticleCategoryLink as Link,
1219 eZArticle_ArticlePermission AS Permission,
1220 eZArticle_Category AS Category,
1221 eZArticle_Article AS Article LEFT JOIN eZArticle_ArticleKeyword AS ArtKey ON
1222 Article.ID=ArtKey.ArticleID
1223 WHERE (
1224 ( $loggedInSQL ($groupSQL Permission.GroupID='-1') AND Permission.ReadPermission='1' )
1225 )
1226 AND Article.IsPublished = '1'
1227 AND Permission.ObjectID=Article.ID
1228 AND Link.ArticleID=Article.ID
1229 AND Category.ID=Link.CategoryID
1230 AND Category.ExcludeFromSearch = '0'
1231 $conditions
1232 ORDER BY Article.Name
1233 $limit_sql";
1234 $db->array_query( $contents, $sql );
1235 if ( !is_bool( $offset ) )
1236 {
1237 $ret = array();
1238 foreach( $contents as $content )
1239 {
1240 $ret[] = $as_object ? new eZArticle( $content[$db->fieldName("ArticleID")] ) : $content[$db->fieldName("ArticleID")];
1241 }
1242 }
1243 else
1244 $ret = $contents[0][$db->fieldName("ArticleCount")];
1245 return $ret;
1246 }
1247
1251 function setIsPublished( $value, $user = false, $as_script = false )
1252 {
1253 if ( !is_a( $user, "eZUser" ) )
1254 $user =& eZUser::currentUser();
1255
1256 $category = $this->categoryDefinition();
1257 if ( is_a( $category, "eZArticleCategory" ) )
1258 $editorID = $category->editorGroup( false );
1259
1260 if ( is_numeric ( $editorID ) && ( $editorID > 0 ) && $as_script == false )
1261 {
1262 $group = new eZUserGroup( $editorID );
1263 if ( $group->isMember( $user ) or ( $user->hasRootAccess() ) )
1264 {
1265 if ( $value == 0 )
1266 $this->IsPublished = "0";
1267 else
1268 $this->IsPublished = "1";
1269 }
1270 else
1271 {
1272 if ( $value == 0 )
1273 $this->IsPublished = "0";
1274 else
1275 {
1276 $this->IsPublished = "2";
1277 $this->sendPendingMail( );
1278 }
1279 }
1280 }
1281 else if ( $value == true )
1282 {
1283 $this->IsPublished = "1";
1284 }
1285 else
1286 {
1287 $this->IsPublished = "0";
1288 }
1289 }
1290
1291
1297 function categories( $as_object = true )
1298 {
1299 $db =& eZDB::globalDatabase();
1300
1301 $ret = array();
1302 $db->array_query( $category_array, "SELECT * FROM eZArticle_ArticleCategoryLink WHERE ArticleID='$this->ID'" );
1303
1304 if ( $as_object )
1305 {
1306 foreach ( $category_array as $category )
1307 {
1308 $ret[] = new eZArticleCategory( $category[$db->fieldName("CategoryID")] );
1309 }
1310 }
1311 else
1312 {
1313 foreach ( $category_array as $category )
1314 {
1315 $ret[] = $category[$db->fieldName("CategoryID")];
1316 }
1317 }
1318
1319 return $ret;
1320 }
1321
1325 function removeFromCategories()
1326 {
1327 $db =& eZDB::globalDatabase();
1328
1329 $db->query( "DELETE FROM eZArticle_ArticleCategoryLink WHERE ArticleID='$this->ID'" );
1330 }
1331
1335 function addImage( $value, $placement = false )
1336 {
1337 $db =& eZDB::globalDatabase();
1338
1339 if( is_a( $value, "eZImage" ) )
1340 $value = $value->id();
1341
1342 $db->query_single( $res, "SELECT count( * ) as Count FROM eZArticle_ArticleImageLink WHERE ArticleID='$this->ID' AND ImageID='$value'" );
1343 if( $res[$db->fieldName("Count")] == 0 )
1344 {
1345 $db->begin( );
1346
1347 $db->lock( "eZArticle_ArticleImageLink" );
1348
1349 if ( is_bool( $placement ) )
1350 {
1351 $db->array_query( $image_array, "SELECT ID, ImageID, Placement, Created FROM eZArticle_ArticleImageLink WHERE ArticleID='$this->ID' ORDER BY Placement DESC" );
1352
1353 if ( $image_array[0][$db->fieldName("Placement")] == "0" )
1354 {
1355 $placement=1;
1356 for ( $i=0; $i < count($image_array); $i++ )
1357 {
1358 $imageLinkID = $image_array[$i][$db->fieldName("ID")];
1359 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$placement' WHERE ID='$imageLinkID'" );
1360 $image_array[$i][$db->fieldName("Placement")] = $placement;
1361 $placement++;
1362 }
1363 }
1364 $placement = $image_array[0][$db->fieldName("Placement")] + 1;
1365 }
1366
1367 $nextID = $db->nextID( "eZArticle_ArticleImageLink", "ID" );
1368 $timeStamp = (new eZDateTime())->timeStamp( true );
1369
1370 $res = $db->query( "INSERT INTO eZArticle_ArticleImageLink
1371 ( ID, ArticleID, ImageID, Created, Placement )
1372 VALUES
1373 ( '$nextID', '$this->ID', '$value', '$timeStamp', '$placement' )" );
1374
1375 $db->unlock();
1376
1377 if ( $res == false )
1378 $db->rollback( );
1379 else
1380 $db->commit();
1381 }
1382 }
1383
1389 function deleteImage( $value )
1390 {
1391 if ( is_a( $value, "eZImage" ) )
1392 {
1393 $imageID = $value->id();
1394 }
1395 else
1396 $imageID = $value;
1397
1398 $db =& eZDB::globalDatabase();
1399
1400 $db->query( "DELETE FROM eZArticle_ArticleImageDefinition WHERE ArticleID='$this->ID' AND ThumbnailImageID='$imageID'" );
1401
1402 $db->query( "DELETE FROM eZArticle_ArticleImageLink WHERE ArticleID='$this->ID' AND ImageID='$imageID'" );
1403 }
1404
1408 function images( $asObject = true, $OrderBy ="Created" )
1409 {
1410 $db =& eZDB::globalDatabase();
1411
1412 $return_array = array();
1413 $image_array = array();
1414
1415 $db->array_query( $image_array, "SELECT ID, ImageID, Placement, Created FROM eZArticle_ArticleImageLink WHERE ArticleID='$this->ID' ORDER BY $OrderBy" );
1416
1417 // convert the database if placement is not set
1418 if ( count( $image_array ) > 0 )
1419 {
1420 if ( $image_array[0][$db->fieldName("Placement")] == "0" )
1421 {
1422 $placement=1;
1423 for ( $i=0; $i < count($image_array); $i++ )
1424 {
1425 $imageLinkID = $image_array[$i][$db->fieldName("ID")];
1426 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$placement' WHERE ID='$imageLinkID'" );
1427
1428 $image_array[$i][$db->fieldName("Placement")] = $placement;
1429 $placement++;
1430 }
1431 }
1432 }
1433
1434 for ( $i=0; $i < count($image_array); $i++ )
1435 {
1436 $return_array[$i]["Image"] = $asObject ? new eZImage( $image_array[$i][$db->fieldName("ImageID")] ) : $image_array[$i][$db->fieldName("ImageID")];
1437 $return_array[$i]["Placement"] = $image_array[$i][$db->fieldName("Placement")];
1438 }
1439
1440 return $return_array;
1441 }
1442
1443
1444
1448 function moveImageUp( $id )
1449 {
1450 $db =& eZDB::globalDatabase();
1451
1452 $db->query_single( $qry, "SELECT * FROM eZArticle_ArticleImageLink
1453 WHERE ArticleID='$this->ID' AND ImageID='$id'" );
1454
1455 if ( is_numeric( $qry[$db->fieldName("ID")] ) )
1456 {
1457 $linkID = $qry[$db->fieldName("ID")];
1458
1459 $placement = $qry[$db->fieldName("Placement")];
1460
1461 $db->query_single( $qry, "SELECT ID, Placement FROM eZArticle_ArticleImageLink
1462 WHERE Placement<'$placement' AND ArticleID='$this->ID'
1463 ORDER BY Placement DESC" );
1464
1465 $newPlacement = $qry[$db->fieldName("Placement")];
1466 $listid = $qry[$db->fieldName("ID")];
1467
1468 if ( $newPlacement == $placement )
1469 {
1470 $placement += 1;
1471 }
1472
1473 if ( is_numeric( $listid ) )
1474 {
1475 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$newPlacement' WHERE ID='$linkID'" );
1476 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$placement' WHERE ID='$listid'" );
1477 }
1478 }
1479 }
1480
1484 function moveImageDown( $id )
1485 {
1486 $db =& eZDB::globalDatabase();
1487
1488 $db->query_single( $qry, "SELECT * FROM eZArticle_ArticleImageLink
1489 WHERE ArticleID='$this->ID' AND ImageID='$id'" );
1490
1491 if ( is_numeric( $qry[$db->fieldName("ID")] ) )
1492 {
1493 $linkID = $qry[$db->fieldName("ID")];
1494
1495 $placement = $qry[$db->fieldName("Placement")];
1496
1497 $db->query_single( $qry, "SELECT ID, Placement FROM eZArticle_ArticleImageLink
1498 WHERE Placement>'$placement' AND ArticleID='$this->ID' ORDER BY Placement ASC" );
1499
1500 $newPlacement = $qry[$db->fieldName("Placement")];
1501 $listid = $qry[$db->fieldName("ID")];
1502
1503 if ( $newPlacement == $placement )
1504 {
1505 $newPlacement += 1;
1506 }
1507
1508 if ( is_numeric( $listid ) )
1509 {
1510 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$newPlacement' WHERE ID='$linkID'" );
1511 $db->query( "UPDATE eZArticle_ArticleImageLink SET Placement='$placement' WHERE ID='$listid'" );
1512 }
1513 }
1514 }
1515
1521 function setThumbnailImage( $image )
1522 {
1523 if ( is_a( $image, "eZImage" ) )
1524 {
1525 $db =& eZDB::globalDatabase();
1526 $res_array = array();
1527
1528 $imageID = $image->id();
1529
1530 $db->array_query( $res_array, "SELECT COUNT(*) AS Number FROM eZArticle_ArticleImageDefinition
1531 WHERE
1532 ArticleID='$this->ID'" );
1533
1534 if ( $res_array[0][$db->fieldName("Number")] == "1" )
1535 {
1536 $db->query( "UPDATE eZArticle_ArticleImageDefinition
1537 SET
1538 ThumbnailImageID='$imageID'
1539 WHERE
1540 ArticleID='$this->ID'" );
1541 }
1542 else
1543 {
1544 $db->begin( );
1545 $forumID = $this->forum( false );
1546 $nextID = $db->nextID( "eZArticle_ArticleImageDefinition" );
1547 $query = "INSERT INTO eZArticle_ArticleImageDefinition
1548 ( ID, ArticleID, ThumbnailImageID, ForumID )
1549 VALUES
1550 ( '$nextID', '$this->ID', '$imageID', '$forumID' )";
1551
1552 $res = $db->query( $query );
1553 $db->unlock();
1554
1555 if ( $res == false )
1556 $db->rollback( );
1557 else
1558 $db->commit();
1559
1560 }
1561 }
1562 else if ( $image == false )
1563 {
1564 $db =& eZDB::globalDatabase();
1565
1566 $db->array_query( $res_array, "SELECT COUNT(*) AS Number FROM eZArticle_ArticleImageDefinition
1567 WHERE
1568 ArticleID='$this->ID'" );
1569
1570 if ( $res_array[0][$db->fieldName("Number")] == "1" )
1571 {
1572 $db->query( "DELETE FROM eZArticle_ArticleImageDefinition
1573 WHERE
1574 ArticleID='$this->ID'" );
1575 }
1576 }
1577 }
1578
1582 function thumbnailImage( $as_object = true )
1583 {
1584 $ret = false;
1585 $db =& eZDB::globalDatabase();
1586 $res_array = array();
1587
1588 $query = "SELECT * FROM eZArticle_ArticleImageDefinition
1589 WHERE
1590 ArticleID='$this->ID'";
1591
1592 $db->array_query( $res_array, $query );
1593
1594 if ( count( $res_array ) == 1 )
1595 {
1596 $id = $res_array[0][$db->fieldName("ThumbnailImageID")];
1597 if ( $id != "NULL" )
1598 {
1599 $ret = $as_object ? new eZImage( $id ) : $id;
1600 }
1601 }
1602
1603 return $ret;
1604 }
1605
1609 function addMedia( $value )
1610 {
1611 $db =& eZDB::globalDatabase();
1612
1613 if( is_a( $value, "eZMedia" ) )
1614 $value = $value->id();
1615
1616 $db->query_single( $res, "SELECT count( * ) as Count FROM eZArticle_ArticleMediaLink WHERE ArticleID='$this->ID' AND MediaID='$value'" );
1617 if( $res[$db->fieldName("Count")] == 0 )
1618 {
1619 $db->begin( );
1620
1621 $db->lock( "eZArticle_ArticleMediaLink" );
1622
1623 $nextID = $db->nextID( "eZArticle_ArticleMediaLink", "ID" );
1624 $timeStamp = (new eZDateTime())->timeStamp( true );
1625
1626 $res = $db->query( "INSERT INTO eZArticle_ArticleMediaLink
1627 ( ID, ArticleID, MediaID, Created )
1628 VALUES
1629 ( '$nextID', '$this->ID', '$value', '$timeStamp' )" );
1630
1631 $db->unlock();
1632
1633 if ( $res == false )
1634 $db->rollback( );
1635 else
1636 $db->commit();
1637 }
1638 }
1639
1645 function deleteMedia( $value )
1646 {
1647 if ( is_a( $value, "eZMedia" ) )
1648 {
1649 $mediaID = $value->id();
1650 }
1651 else
1652 $mediaID = $value;
1653
1654 $db =& eZDB::globalDatabase();
1655
1656 $db->query( "DELETE FROM eZArticle_ArticleMediaDefinition WHERE ArticleID='$this->ID' AND ThumbnailMediaID='$mediaID'" );
1657
1658 $db->query( "DELETE FROM eZArticle_ArticleMediaLink WHERE ArticleID='$this->ID' AND MediaID='$mediaID'" );
1659 }
1660
1664 function media( $asObject = true )
1665 {
1666 $db =& eZDB::globalDatabase();
1667
1668 $return_array = array();
1669 $media_array = array();
1670
1671 $db->array_query( $media_array, "SELECT MediaID, Created FROM eZArticle_ArticleMediaLink WHERE ArticleID='$this->ID' ORDER BY Created" );
1672
1673 for ( $i=0; $i < count($media_array); $i++ )
1674 {
1675 $return_array[$i] = $asObject ? new eZMedia( $media_array[$i][$db->fieldName("MediaID")] ) : $media_array[$i][$db->fieldName("MediaID")];
1676 }
1677
1678 return $return_array;
1679 }
1680
1681
1686 function addFile( $value )
1687 {
1688 if ( is_a( $value, "eZVirtualFile" ) )
1689 {
1690 $fileID = $value->id();
1691 }
1692 else
1693 $fileID = $value;
1694
1695 $db =& eZDB::globalDatabase();
1696
1697 $db->begin( );
1698
1699 $db->lock( "eZArticle_ArticleFileLink" );
1700
1701 $nextID = $db->nextID( "eZArticle_ArticleFileLink", "ID" );
1702
1703 $timeStamp = (new eZDateTime())->timeStamp( true );
1704
1705 $res = $db->query( "INSERT INTO eZArticle_ArticleFileLink
1706 ( ID, ArticleID, FileID, Created ) VALUES ( '$nextID', '$this->ID', '$fileID', '$timeStamp' )" );
1707
1708 $db->unlock();
1709
1710 if ( $res == false )
1711 $db->rollback( );
1712 else
1713 $db->commit();
1714 }
1715
1722 function deleteFile( $value )
1723 {
1724 if ( is_a( $value, "eZVirtualFile" ) )
1725 {
1726 $fileID = $value->id();
1727
1728 }
1729 else
1730 $fileID = $value;
1731
1732 $db =& eZDB::globalDatabase();
1733 $db->query( "DELETE FROM eZArticle_ArticleFileLink WHERE ArticleID='$this->ID' AND FileID='$fileID'" );
1734 }
1735
1739 function files( $as_object = true )
1740 {
1741 $db =& eZDB::globalDatabase();
1742
1743 $return_array = array();
1744 $file_array = array();
1745
1746 $db->array_query( $file_array, "SELECT FileID, Created FROM eZArticle_ArticleFileLink WHERE ArticleID='$this->ID' ORDER BY Created" );
1747
1748 for ( $i=0; $i < count($file_array); $i++ )
1749 {
1750 $id = $file_array[$i][$db->fieldName("FileID")];
1751 $return_array[$i] = $as_object ? new eZVirtualFile( $id, false ) : $id;
1752 }
1753
1754 return $return_array;
1755 }
1756
1760 function deleteAttribute( $value )
1761 {
1762 if ( is_a( $value, "eZArticleAttribute" ) )
1763 {
1764 $db =& eZDB::globalDatabase();
1765
1766 $attributeID = $value->id();
1767
1768 $db->query( "DELETE FROM eZArticle_AttributeValue WHERE ArticleID='$this->ID' AND AttributeID='$attributeID'" );
1769 }
1770 }
1771
1775 function attributes( $as_object = true )
1776 {
1777 $db =& eZDB::globalDatabase();
1778
1779 $return_array = array();
1780 $attribute_array = array();
1781
1782 $db->array_query( $attribute_array, "SELECT Value.AttributeID, Attr.Placement FROM eZArticle_AttributeValue as Value, eZArticle_Attribute as Attr
1783 WHERE Attr.ID = Value.AttributeID AND Value.ArticleID='$this->ID' ORDER BY Attr.TypeID, Attr.Placement" );
1784
1785 for ( $i=0; $i < count( $attribute_array ); $i++ )
1786 {
1787 $id = $attribute_array[$i][$db->fieldName("AttributeID")];
1788 $return_array[$i] = $as_object ? new eZArticleAttribute( $id, false ) : $id;
1789 }
1790
1791 return $return_array;
1792 }
1793
1794
1798 function deleteAttributesByType( $type )
1799 {
1800 $ret = false;
1801
1802 if ( is_a( $type, "eZArticleType" ) )
1803 {
1804 $db =& eZDB::globalDatabase();
1805
1806 $typeID = $type->id();
1807
1808 $return_array = array();
1809 $attribute_array = array();
1810
1811 $db->array_query( $attribute_array, "SELECT Value.ID FROM eZArticle_AttributeValue AS Value, eZArticle_Attribute AS Attr
1812 WHERE Value.ArticleID='$this->ID' AND Value.AttributeID=Attr.ID AND Attr.TypeID='$typeID'" );
1813
1814 for ( $i=0; $i < count( $attribute_array ); $i++ )
1815 {
1816 $valueID = $attribute_array[$i][$db->fieldName("ID")];
1817 $db->query( "DELETE FROM eZArticle_AttributeValue WHERE ID='$valueID'" );
1818 }
1819
1820 $ret = true;
1821 }
1822 return $ret;
1823 }
1824
1828 function types( $as_object = true )
1829 {
1830 $db =& eZDB::globalDatabase();
1831
1832 $return_array = array();
1833 $type_array = array();
1834
1835 $db->array_query( $type_array, "SELECT Attr.TypeID AS TypeID FROM eZArticle_Attribute AS Attr, eZArticle_AttributeValue AS Value WHERE Value.ArticleID='$this->ID' AND Attr.ID = Value.AttributeID GROUP BY Attr.TypeID" );
1836
1837 for ( $i=0; $i < count( $type_array ); $i++ )
1838 {
1839 $id = $type_array[$i][$db->fieldName("TypeID")];
1840 $return_array[$i] = $as_object ? new eZArticleType( $id, false ) : $id;
1841 }
1842
1843 return $return_array;
1844 }
1845
1849 function hasType( $type )
1850 {
1851 $ret = false;
1852 if ( is_a( $value, "eZArticleType" ) )
1853 {
1854 $typeID = $value->id();
1855
1856 $db =& eZDB::globalDatabase();
1857
1858 $return_array = array();
1859 $type_array = array();
1860
1861 $db->array_query( $type_array, "SELECT Attr.TypeID AS TypeID FROM eZArticle_Attribute AS Attr, eZArticle_AttributeValue AS Value WHERE Value.ArticleID='$this->ID' AND Attr.ID = Value.AttributeID AND Attr.TypeID='$typeID'" );
1862
1863 if( count( $type_array ) > 0 )
1864 {
1865 $ret = true;
1866 }
1867 }
1868 return $ret;
1869 }
1870
1875 function existsInCategory( $category )
1876 {
1877 $ret = false;
1878 if ( is_a( $category, "eZArticleCategory" ) )
1879 {
1880 $db =& eZDB::globalDatabase();
1881 $catID = $category->id();
1882
1883 $db->array_query( $ret_array, "SELECT ID FROM eZArticle_ArticleCategoryLink
1884 WHERE ArticleID='$this->ID' AND CategoryID='$catID'" );
1885
1886 if ( count( $ret_array ) == 1 )
1887 {
1888 $ret = true;
1889 }
1890 }
1891 return $ret;
1892 }
1893
1912 function &search( &$queryText, $sortMode=time, $fetchPublished=false, $offset=0, $limit=10, $params = array(), &$SearchTotalCount = false )
1913 {
1914 $db =& eZDB::globalDatabase();
1915
1916 $queryText = $db->escapeString( $queryText );
1917
1918 // Build the ORDER BY
1919 $OrderBy = "eZArticle_ArticleWordLink.Frequency DESC";
1920 switch( $sortMode )
1921 {
1922 case "alpha" :
1923 {
1924 $OrderBy = "eZArticle_Article.Name DESC";
1925 }
1926 break;
1927 }
1928
1929 if ( $fetchPublished == true )
1930 {
1931 $fetchText = "";
1932 }
1933 else
1934 {
1935 $fetchText = "AND eZArticle_Article.IsPublished = '1'";
1936 }
1937
1938 $usePermission = true;
1939
1940 $user =& eZUser::currentUser();
1941
1942 // Build the permission
1943 $loggedInSQL = "";
1944 $groupSQL = "";
1945 if ( $user )
1946 {
1947 $groups =& $user->groups( false );
1948
1949 foreach ( $groups as $group )
1950 {
1951 $groupSQL .= " ( Permission.GroupID='$group' AND CategoryPermission.GroupID='$group' ) OR
1952 ( Permission.GroupID='$group' AND CategoryPermission.GroupID='-1' ) OR
1953 ( Permission.GroupID='-1' AND CategoryPermission.GroupID='$group' ) OR
1954 ";
1955 }
1956 $currentUserID = $user->id();
1957 $loggedInSQL = "eZArticle_Article.AuthorID=$currentUserID OR";
1958
1959 if ( $user->hasRootAccess() )
1960 $usePermission = false;
1961 }
1962
1963 $loggedInSQL = "( ( ( $groupSQL Permission.GroupID='-1' AND CategoryPermission.GroupID='-1' ) AND Permission.ReadPermission='1' AND CategoryPermission.ReadPermission='1' ) ) AND";
1964
1965 if ( $usePermission )
1966 $permissionSQL = $loggedInSQL;
1967 else
1968 $permissionSQL = "";
1969
1970 // stop word frequency
1971 $ini =& eZINI::instance( 'site.ini' );
1972 $StopWordFrequency = $ini->variable( "eZArticleMain", "StopWordFrequency" );
1973
1974
1975 $query = new eZQuery( "eZArticle_Word.Word", $queryText );
1976 $query->setIsLiteral( true );
1977 // $query->setPartialCompare( true );
1978 $query->setStopWordColumn( "eZArticle_Word.Frequency" );
1979 $query->setStopWordPercent( $StopWordFrequency );
1980 $searchSQL = $query->buildQuery();
1981
1982 $authorSQL = "";
1983 $dateSQL = "";
1984 $catSQL = "";
1985 $typeTables = "";
1986 $typeSQL = "";
1987 $sectionsSQL = "";
1988 $photoSQL = "";
1989 $photoTables = "";
1990
1991 if ( isset( $params["FromDate"] ) )
1992 {
1993 $fromdate = $params["FromDate"];
1994 if( is_a( $fromdate, "eZDateTime" ) )
1995 $fromdate = $fromdate->timeStamp();
1996 $dateSQL .= "AND eZArticle_Article.Published >= '$fromdate'";
1997 }
1998 if ( isset( $params["ToDate"] ) )
1999 {
2000 $todate = $params["ToDate"];
2001 if( is_a( $todate, "eZDateTime" ) )
2002 $todate = $todate->timeStamp();
2003 $dateSQL .= "AND eZArticle_Article.Published <= '$todate'";
2004 }
2005 if ( isset( $params["Categories"] ) )
2006 {
2007 $cats = $params["Categories"];
2008 $sql = "";
2009 $i = 0;
2010 foreach( $cats as $cat )
2011 {
2012 if ( $i > 0 )
2013 $sql .= "OR ";
2014 $sql .= "Category.ID = '$cat' ";
2015 ++$i;
2016 }
2017 if ( count( $cats ) > 0 )
2018 {
2019 $catSQL = "AND ( $sql ) AND Category.ID=eZArticle_ArticleCategoryLink.CategoryID
2020 AND eZArticle_Article.ID=eZArticle_ArticleCategoryLink.ArticleID";
2021 }
2022 }
2023 if ( isset( $params["Type"] ) )
2024 {
2025 $type = $params["Type"];
2026 $typeSQL = "AND eZArticle_Attribute.TypeID='$type'
2027 AND eZArticle_Attribute.ID=eZArticle_AttributeValue.AttributeID
2028 AND eZArticle_AttributeValue.ArticleID=eZArticle_Article.ID";
2029 $typeTables = "eZArticle_Attribute, eZArticle_AttributeValue, ";
2030 }
2031 if ( isset( $params["AuthorID"] ) )
2032 {
2033 $author = $params["AuthorID"];
2034 $authorSQL = "AND eZArticle_Article.ContentsWriterID='$author'";
2035 }
2036 if ( isset( $params["SectionsList"] ) )
2037 {
2038 $sectionsList = $params["SectionsList"];
2039 $sectionsArray = explode( ",", $sectionsList );
2040 if ( is_numeric( $sectionsArray[0] ) )
2041 {
2042 $sectionsSQL .= "AND ( Category.SectionID='$sectionsArray[0]'";
2043 for ( $i=1; $i<count( $sectionsArray ); $i++ )
2044 {
2045 $sectionsSQL .= " OR Category.SectionID='$sectionsArray[$i]'";
2046 }
2047 $sectionsSQL .= " ) ";
2048 }
2049 }
2050 if ( isset( $params["PhotographerID"] ) )
2051 {
2052 $photo = $params["PhotographerID"];
2053 $photoSQL = "AND eZImageCatalogue_Image.PhotographerID='$photo'
2054 AND eZImageCatalogue_Image.ID=eZArticle_ArticleImageLink.ImageID
2055 AND eZArticle_Article.ID=eZArticle_ArticleImageLink.ArticleID";
2056 $photoTables = "eZArticle_ArticleImageLink, eZImageCatalogue_Image,";
2057 }
2058
2059
2060 if ( isset($params["SearchExcludedArticles"]) && $params["SearchExcludedArticles"] == "true" )
2061 $excludeFromSearchSQL = " ";
2062 else
2063 $excludeFromSearchSQL = " AND Category.ExcludeFromSearch = '0' ";
2064
2065 // special search for MySQL, mimic subselects ;)
2066 if ( $db->isA() == "mysql" )
2067 {
2068 $queryArray = explode( " ", trim( $queryText ) );
2069
2070 $db->query( "CREATE TEMPORARY TABLE eZArticle_SearchTemp( ArticleID int )" );
2071
2072 $count = 1;
2073 foreach ( $queryArray as $queryWord )
2074 {
2075 $queryWord = trim( $queryWord );
2076
2077 $searchSQL = " ( eZArticle_Word.Word = '$queryWord' AND eZArticle_Word.Frequency < '$StopWordFrequency' ) ";
2078 // $searchSQL = " ( (eZArticle_Word.Word LIKE '$queryWord') AND eZArticle_Word.Frequency < '$StopWordFrequency' ) ";
2079
2080 $queryString = "INSERT INTO eZArticle_SearchTemp ( ArticleID ) SELECT DISTINCT eZArticle_Article.ID AS ArticleID
2081 FROM eZArticle_Article,
2082 eZArticle_ArticleWordLink,
2083 eZArticle_Word,
2084 eZArticle_ArticleCategoryLink as Link,
2085 $typeTables
2086 $photoTables
2087 eZArticle_ArticleCategoryDefinition as Definition,
2088 eZArticle_ArticlePermission as Permission,
2089 eZArticle_Category AS Category,
2090 eZArticle_CategoryPermission as CategoryPermission
2091
2092 WHERE
2093 $permissionSQL
2094 $searchSQL
2095 $dateSQL
2096 $catSQL
2097 $typeSQL
2098 $authorSQL
2099 $photoSQL
2100 $sectionsSQL
2101 AND
2102 ( eZArticle_Article.ID=eZArticle_ArticleWordLink.ArticleID
2103 AND Definition.ArticleID=eZArticle_Article.ID
2104 AND Definition.CategoryID=Category.ID
2105 $excludeFromSearchSQL
2106 AND eZArticle_ArticleWordLink.WordID=eZArticle_Word.ID
2107 AND Permission.ObjectID=eZArticle_Article.ID
2108 AND CategoryPermission.ObjectID=Definition.CategoryID
2109 $fetchText
2110 AND Link.ArticleID=eZArticle_Article.ID
2111 )
2112 ORDER BY $OrderBy";
2113
2114 $db->query( $queryString );
2115
2116 // check if this is a stop word
2117 $queryString = "SELECT Frequency FROM eZArticle_Word WHERE Word='$queryWord'";
2118
2119 $db->query_single( $WordFreq, $queryString, array( "LIMIT" => 1 ) );
2120
2121 if ( is_array( $WordFreq ) && $WordFreq["Frequency"] <= $StopWordFrequency )
2122 $count += 1;
2123 }
2124 $count -= 1;
2125
2126 $queryString = "SELECT ArticleID, Count(*) AS Count FROM eZArticle_SearchTemp GROUP BY ArticleID HAVING Count>='$count'";
2127
2128 $db->array_query( $article_array, $queryString );
2129
2130 // $db->array_query( $article_array, $queryString, array( "Limit" => $limit, "Offset" => $offset ) );
2131
2132 $db->query( "DROP TABLE eZArticle_SearchTemp" );
2133
2134 $SearchTotalCount = count( $article_array );
2135 if ( $limit >= 0 )
2136 $article_array =& array_slice( $article_array, $offset, $limit );
2137 }
2138 else
2139 {
2140 $queryString = "SELECT DISTINCT eZArticle_Article.ID AS ArticleID, eZArticle_Article.Published, eZArticle_Article.Name, eZArticle_ArticleWordLink.Frequency
2141 FROM eZArticle_Article,
2142 eZArticle_ArticleWordLink,
2143 eZArticle_Word,
2144 eZArticle_ArticleCategoryLink,
2145 $catDefTable
2146 $catTable
2147 $typeTables
2148 $photoTables
2149 eZArticle_ArticlePermission
2150 WHERE
2151 $searchSQL
2152 $dateSQL
2153 $catSQL
2154 $typeSQL
2155 $authorSQL
2156 $photoSQL
2157 AND
2158 ( eZArticle_Article.ID=eZArticle_ArticleWordLink.ArticleID
2159 AND eZArticle_ArticleCategoryDefinition.ArticleID=eZArticle_Article.ID
2160 AND eZArticle_ArticleCategoryDefinition.CategoryID=eZArticle_Category.ID
2161 $excludeFromSearchSQL
2162 AND eZArticle_ArticleWordLink.WordID=eZArticle_Word.ID
2163 AND eZArticle_ArticlePermission.ObjectID=eZArticle_Article.ID
2164 $fetchText
2165 AND eZArticle_ArticleCategoryLink.ArticleID=eZArticle_Article.ID AND
2166 ( $loggedInSQL ($groupSQL eZArticle_ArticlePermission.GroupID='-1')
2167 AND eZArticle_ArticlePermission.ReadPermission='1'
2168 )
2169 )
2170 ORDER BY $OrderBy";
2171
2172 $db->array_query( $article_array, $queryString );
2173
2174 $SearchTotalCount = count( $article_array );
2175 $article_array =& array_slice( $article_array, $offset, $limit );
2176 }
2177
2178 for ( $i = 0; $i < count($article_array); $i++ )
2179 {
2180 $return_array[$i] = new eZArticle( $article_array[$i][$db->fieldName( "ArticleID" )], false );
2181 }
2182
2183 return $return_array;
2184 }
2185
2193 function &searchTitle( &$queryText, $fetchPublished=false, &$SearchTotalCount = false, $categoryID = false )
2194 {
2195 $db =& eZDB::globalDatabase();
2196
2197 $queryText = $db->escapeString( $queryText );
2198
2199 // Build the ORDER BY
2200 $OrderBy = "eZArticle_Article.Published DESC";
2201
2202 if ( $fetchPublished == true )
2203 $fetchText = "";
2204 else
2205 $fetchText = "AND eZArticle_Article.IsPublished = '1'";
2206
2207 if ( $categoryID )
2208 $categoryText = "AND eZArticle_ArticleCategoryLink.CategoryID = '$categoryID'";
2209 else
2210 $categoryText = "";
2211
2212 $usePermission = true;
2213
2214 $user =& eZUser::currentUser();
2215
2216 $query = "SELECT eZArticle_Article.ID AS ArticleID FROM eZArticle_Article, eZArticle_ArticleCategoryLink WHERE
2217 eZArticle_Article.Name LIKE '%$queryText%' AND
2218 eZArticle_Article.ID = eZArticle_ArticleCategoryLink.ArticleID
2219 $fetchText
2220 $categoryText GROUP BY eZArticle_Article.ID ORDER BY eZArticle_Article.Published";
2221
2222 $db->array_query( $article_array, $query );
2223 $SearchTotalCount = count( $article_array );
2224
2225 for ( $i = 0; $i < count( $article_array ); $i++ )
2226 {
2227 $return_array[$i] = new eZArticle( $article_array[$i][$db->fieldName( "ArticleID" )], false );
2228 }
2229
2230 return $return_array;
2231 }
2232
2236 function articleCount( $fetchNonPublished=true, $excludeFromSearch=false )
2237 {
2238 $db =& eZDB::globalDatabase();
2239
2240 $OrderBy = "Article.Published DESC";
2241 //switch( $sortMode )
2242 //{
2243 // case "alpha" :
2244 // {
2245 // $OrderBy = "Article.Name DESC";
2246 // }
2247 // break;
2248 //}
2249
2250 $ini =& eZINI::instance( 'site.ini' );
2251 $ExcludeCategories = "";
2252 if ( $ini->hasVariable( "eZArticleMain", "ExcludeCategories" ) )
2253 {
2254 $ExcludeCategories = $ini->variable( "eZArticleMain", "ExcludeCategories" );
2255 }
2256
2257
2258 $return_array = array();
2259 $article_array = array();
2260
2261 $usePermission = true;
2262
2263 $user =& eZUser::currentUser();
2264 $currentUserSQL = "";
2265 $groupSQL = "";
2266 if ( $user )
2267 {
2268 $groups =& $user->groups( false );
2269
2270 foreach ( $groups as $group )
2271 {
2272 $groupSQL .= " ( Permission.GroupID='$group' AND CategoryPermission.GroupID='$group' ) OR
2273 ( Permission.GroupID='$group' AND CategoryPermission.GroupID='-1' ) OR
2274 ( Permission.GroupID='-1' AND CategoryPermission.GroupID='$group' ) OR
2275 ";
2276 }
2277 $currentUserID = $user->id();
2278 $currentUserSQL = "Article.AuthorID=$currentUserID OR";
2279
2280 if ( $user->hasRootAccess() )
2281 $usePermission = false;
2282 }
2283 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL Permission.GroupID='-1' AND CategoryPermission.GroupID='-1' ) AND Permission.ReadPermission='1' AND CategoryPermission.ReadPermission='1' ) ) ";
2284
2285 if ( $usePermission )
2286 $permissionSQL = $loggedInSQL;
2287 else
2288 $permissionSQL = "";
2289
2290 // fetch only published articles
2291 if ( $fetchNonPublished == true )
2292 {
2293 if ( $permissionSQL == "" )
2294 $publishedSQL = " Article.IsPublished = '0' AND ";
2295 else
2296 $publishedSQL = " AND Article.IsPublished = '0' AND ";
2297 }
2298 // fetch only non-published articles
2299 else
2300 {
2301 if ( $permissionSQL == "" )
2302 $publishedSQL = " Article.IsPublished = '1' AND ";
2303 else
2304 $publishedSQL = " AND Article.IsPublished = '1' AND ";
2305 }
2306
2307 // fetch only published articles
2308 if ( $fetchNonPublished == "pending" )
2309 {
2310 if ( $permissionSQL == "" )
2311 $publishedSQL = " Article.IsPublished = '2' AND ";
2312 else
2313 $publishedSQL = " AND Article.IsPublished = '2' AND ";
2314 }
2315
2316 if ( $excludeFromSearch )
2317 $excludeSQL = " AND Category.ExcludeFromSearch = '0'";
2318 else
2319 $excludeSQL = "";
2320
2321
2322
2323 if ($ExcludeCategories && $ExcludeCategories<>"") $excludeSQL .= " AND Category.ID NOT IN (".$ExcludeCategories.")";
2324
2325
2326 $query = "SELECT COUNT( DISTINCT Article.ID ) as Count
2327 FROM eZArticle_ArticleCategoryDefinition as Definition,
2328 eZArticle_Article AS Article,
2329 eZArticle_ArticleCategoryLink as Link,
2330 eZArticle_ArticlePermission AS Permission,
2331 eZArticle_CategoryPermission as CategoryPermission,
2332 eZArticle_Category AS Category
2333 WHERE $permissionSQL
2334 $publishedSQL
2335 Permission.ObjectID=Article.ID
2336 AND Link.ArticleID=Article.ID
2337 AND Category.ID=Link.CategoryID
2338 AND Category.ID=Link.CategoryID
2339 AND Definition.ArticleID=Article.ID
2340 AND CategoryPermission.ObjectID=Definition.CategoryID
2341 $excludeSQL ";
2342
2343
2344 $db->array_query( $article_array, $query );
2345
2346 return $article_array[0][$db->fieldName("Count")];
2347 }
2348
2352 function &articles( $sortMode="time", $fetchNonPublished=true,
2353 $offset=0, $limit=50 )
2354 {
2355 $db =& eZDB::globalDatabase();
2356
2357 $OrderBy = "Article.Published DESC";
2358 $GroupBy = "Article.Published";
2359 switch( $sortMode )
2360 {
2361 case "alpha" :
2362 {
2363 $GroupBy = "Article.Name";
2364 $OrderBy = "Article.Name DESC";
2365 }
2366 break;
2367 }
2368
2369 $ini =& eZINI::instance( 'site.ini' );
2370 $ExcludeCategories = "";
2371 if ( $ini->hasVariable( "eZArticleMain", "ExcludeCategories" ) )
2372 {
2373 $ExcludeCategories = $ini->variable( "eZArticleMain", "ExcludeCategories" );
2374 }
2375
2376
2377 $return_array = array();
2378 $article_array = array();
2379
2380 $user =& eZUser::currentUser();
2381 $currentUserSQL = "";
2382 $groupSQL = "";
2383 $usePermission = true;
2384 if ( $user )
2385 {
2386 $groups =& $user->groups( false );
2387
2388 foreach ( $groups as $group )
2389 {
2390 $groupSQL .= " ( Permission.GroupID='$group' AND CategoryPermission.GroupID='$group' ) OR
2391 ( Permission.GroupID='$group' AND CategoryPermission.GroupID='-1' ) OR
2392 ( Permission.GroupID='-1' AND CategoryPermission.GroupID='$group' ) OR
2393 ";
2394 }
2395 $currentUserID = $user->id();
2396 $currentUserSQL = "Article.AuthorID=$currentUserID OR";
2397
2398 if ( $user->hasRootAccess() )
2399 $usePermission = false;
2400 }
2401 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL Permission.GroupID='-1' AND CategoryPermission.GroupID='-1' ) AND Permission.ReadPermission='1' AND CategoryPermission.ReadPermission='1' ) ) ";
2402
2403 if ( $usePermission )
2404 $permissionSQL = $loggedInSQL;
2405 else
2406 $permissionSQL = "";
2407
2408 $excludeSQL = " AND Category.ExcludeFromSearch = '0'";
2409
2410 // fetch only published articles
2411 if ( $fetchNonPublished == true )
2412 {
2413 $excludeSQL = "";
2414 if ( $permissionSQL == "" )
2415 $publishedSQL = " Article.IsPublished = '0' AND ";
2416 else
2417 $publishedSQL = " AND Article.IsPublished = '0' AND ";
2418 }
2419 // fetch only non-published articles
2420 else
2421 {
2422 if ( $permissionSQL == "" )
2423 $publishedSQL = " Article.IsPublished = '1' AND ";
2424 else
2425 $publishedSQL = " AND Article.IsPublished = '1' AND ";
2426 }
2427
2428 // fetch only published articles
2429 if ( $fetchNonPublished == "pending" )
2430 {
2431 if ( $permissionSQL == "" )
2432 $publishedSQL = " Article.IsPublished = '2' AND ";
2433 else
2434 $publishedSQL = " AND Article.IsPublished = '2' AND ";
2435 }
2436
2437 if ( $ExcludeCategories && $ExcludeCategories <> "" )
2438 $excludeSQL .= " AND Category.ID NOT IN (".$ExcludeCategories.")";
2439
2440 $query = "SELECT Article.ID as ArticleID
2441 FROM eZArticle_ArticleCategoryDefinition as Definition,
2442 eZArticle_Article AS Article,
2443 eZArticle_ArticleCategoryLink as Link,
2444 eZArticle_ArticlePermission AS Permission,
2445 eZArticle_CategoryPermission as CategoryPermission,
2446 eZArticle_Category AS Category
2447 WHERE $permissionSQL
2448 $publishedSQL
2449 Permission.ObjectID=Article.ID
2450 AND Link.ArticleID=Article.ID
2451 AND Category.ID=Link.CategoryID
2452 $excludeSQL
2453 AND Definition.ArticleID=Article.ID
2454 AND CategoryPermission.ObjectID=Definition.CategoryID
2455 GROUP BY Article.ID, Article.IsPublished, $GroupBy ORDER BY $OrderBy";
2456
2457
2458 $db->array_query( $article_array, $query, array( "Limit" => $limit, "Offset" => $offset ) );
2459
2460 for ( $i=0; $i < count($article_array); $i++ )
2461 {
2462 $return_array[$i] = new eZArticle( $article_array[$i][$db->fieldName("ArticleID")], false );
2463 }
2464
2465 return $return_array;
2466 }
2467
2472 function setCategoryDefinition( $value )
2473 {
2474 if ( is_a( $value, "eZArticleCategory" ) )
2475 {
2476 $db =& eZDB::globalDatabase();
2477
2478 $categoryID = $value->id();
2479
2480 $db->begin( );
2481
2482 $res[] = $db->query( "DELETE FROM eZArticle_ArticleCategoryDefinition
2483 WHERE ArticleID='$this->ID'" );
2484
2485
2486 $db->lock( "eZArticle_ArticleCategoryDefinition" );
2487 $nextID = $db->nextID( "eZArticle_ArticleCategoryDefinition", "ID" );
2488
2489 $query = "INSERT INTO
2490 eZArticle_ArticleCategoryDefinition
2491 ( ID, CategoryID, ArticleID )
2492 VALUES
2493 ( '$nextID',
2494 '$categoryID',
2495 '$this->ID' )";
2496
2497 $res[] = $db->query( $query );
2498
2499
2500 $db->unlock();
2501
2502 if ( in_array( false, $res ) )
2503 $db->rollback( );
2504 else
2505 $db->commit();
2506 }
2507 }
2508
2512 function categoryDefinition( $as_object = true )
2513 {
2514 $db =& eZDB::globalDatabase();
2515
2516 $db->array_query( $res, "SELECT CategoryID FROM
2517 eZArticle_ArticleCategoryDefinition
2518 WHERE ArticleID='$this->ID'" );
2519
2520 $category = false;
2521 if ( count( $res ) == 1 )
2522 {
2523 $id = $res[0][$db->fieldName("CategoryID")];
2524 $category = $as_object ? new eZArticleCategory( $id ) : $id;
2525 }
2526 else
2527 {
2528 print( "<br><b>Failed to get article category definition for ID $this->ID</b></br>" );
2529 }
2530
2531 return $category;
2532 }
2533
2541 static public function categoryDefinitionStatic( $id )
2542 {
2543 $db =& eZDB::globalDatabase();
2544
2545 $db->array_query( $res, "SELECT CategoryID FROM
2546 eZArticle_ArticleCategoryDefinition
2547 WHERE ArticleID='$id'" );
2548
2549 if ( count( $res ) == 1 )
2550 return $res[0][$db->fieldName("CategoryID")];
2551 else
2552 return false;
2553 }
2554
2558 function GetCategory( $articleSectionID = 0 )
2559 {
2560
2561 $db =& eZDB::globalDatabase();
2562
2563 $categoryQueryWithSection="SELECT DISTINCT eZArticle_Category.ID AS CategoryID
2564 FROM
2565 eZArticle_Article, eZArticle_Category, eZArticle_ArticleCategoryLink
2566 WHERE
2567 eZArticle_Category.ID=eZArticle_ArticleCategoryLink.CategoryID
2568 AND eZArticle_Article.ID=eZArticle_ArticleCategoryLink.ArticleID
2569 AND eZArticle_Article.ID=$this->ID
2570 AND eZArticle_Category.SectionID='$articleSectionID'";
2571
2572 $categoryQueryWithoutSection="SELECT DISTINCT eZArticle_ArticleCategoryDefinition.CategoryID AS CategoryID
2573 FROM
2574 eZArticle_Article, eZArticle_ArticleCategoryDefinition
2575 WHERE
2576 eZArticle_Article.ID=eZArticle_ArticleCategoryDefinition.ArticleID
2577 AND eZArticle_Article.ID=$this->ID";
2578
2579
2580 if ( $articleSectionID > 0 )
2581 {
2582 $db->array_query( $category_array, $categoryQueryWithSection );
2583 if ( count( $category_array ) == 0 )
2584 {
2585 $db->array_query( $category_array, $categoryQueryWithoutSection );
2586 }
2587 }
2588 else
2589 {
2590 $db->array_query( $category_array, $categoryQueryWithoutSection );
2591 }
2592
2593 return $category_array[0][$db->fieldName("CategoryID")];
2594 }
2595
2596
2600 function createForum()
2601 {
2602
2603 }
2604
2608 function forum( $as_object = true )
2609 {
2610
2611 $db =& eZDB::globalDatabase();
2612
2613 $db->array_query( $res, "SELECT ForumID FROM
2614 eZArticle_ArticleForumLink
2615 WHERE ArticleID='$this->ID'" );
2616 $forum = false;
2617 if ( count( $res ) == 1 )
2618 {
2619 if ( $as_object )
2620 $forum = new eZForum( $res[0][$db->fieldName( "ForumID" )] );
2621 else
2622 $forum = $res[0][$db->fieldName( "ForumID" )];
2623 }
2624 else
2625 {
2626 $forum = new eZForum();
2627 $forum->setName( $db->escapeString( $this->Name ) );
2628
2629 $ini =& eZINI::instance( 'site.ini' );
2630 $RequireUserLogin = $ini->variable( "eZArticleMain", "RequireUserLogin" );
2631 if ($RequireUserLogin == "disabled")
2632 $forum->setIsAnonymous('true');
2633
2634 $forum->store();
2635
2636 $forumID = $forum->id();
2637
2638 $db->begin( );
2639
2640 $db->lock( "eZArticle_ArticleForumLink" );
2641
2642 $nextID = $db->nextID( "eZArticle_ArticleForumLink", "ID" );
2643
2644 $res = $db->query( "INSERT INTO eZArticle_ArticleForumLink
2645 ( ID, ArticleID, ForumID )
2646 VALUES
2647 ( '$nextID', '$this->ID', '$forumID' )" );
2648
2649 $db->unlock();
2650
2651 if ( $res == false )
2652 $db->rollback( );
2653 else
2654 $db->commit();
2655
2656
2657 if ( $as_object )
2658 $forum = new eZForum( $forumID );
2659 else
2660 $forum = $forumID;
2661 }
2662 return $forum;
2663 }
2664
2665
2672 public static function isAuthor( $user, $articleID )
2673 {
2674 if( !is_a( $user, "eZUser" ) )
2675 return false;
2676
2677 $db =& eZDB::globalDatabase();
2678 $db->query_single( $res, "SELECT AuthorID from eZArticle_Article WHERE ID='$articleID'");
2679 $authorID = $res[$db->fieldName("AuthorID")];
2680 if( $authorID == $user->id() )
2681 return true;
2682
2683 return false;
2684 }
2685
2689 public static function articleIDFromForum( $ForumID )
2690 {
2691 $db =& eZDB::globalDatabase();
2692
2693 $ArticleID = 0;
2694
2695 $db->array_query( $result, "SELECT ArticleID FROM
2696 eZArticle_ArticleForumLink
2697 WHERE ForumID='$ForumID' GROUP BY ArticleID" );
2698
2699 if( count( $result ) > 0 )
2700 {
2701 $ArticleID = $result[0][$db->fieldName("ArticleID")];
2702 }
2703
2704 return $ArticleID;
2705 }
2706
2710 static public function authorList( $offset = 0, $limit = -1, $sort = false )
2711 {
2712 $sort_text = false;
2713
2714 if ( is_string( $sort ) )
2715 {
2716 switch( $sort )
2717 {
2718 case "count":
2719 {
2720 $sort_text = "ORDER BY Count";
2721 break;
2722 }
2723 default:
2724 case "name":
2725 {
2726 $sort_text = "ORDER BY ContentsWriterID";
2727 break;
2728 }
2729 }
2730 }
2731
2732 $db =& eZDB::globalDatabase();
2733
2734 $db->array_query( $qry_array, "SELECT count( eZArticle_Article.ID ) AS Count, eZUser_Author.Name AS ContentsWriter, eZUser_Author.ID AS ContentsWriterID
2735 FROM eZArticle_Article, eZArticle_ArticleCategoryDefinition, eZUser_Author
2736 WHERE IsPublished='1' AND eZArticle_Article.ID=ArticleID
2737 AND eZArticle_Article.ContentsWriterID=eZUser_Author.ID
2738 GROUP BY eZUser_Author.ID, eZUser_Author.Name $sort_text ",
2739 array( "Limit" => $limit, "Offset" => $offset ) );
2740
2741 return $qry_array;
2742 }
2743
2747 static public function authorArticleList( $authorid, $offset = 0, $limit = -1, $sort = false )
2748 {
2749 $sort_text = '';
2750 if ( is_string( $sort ) )
2751 {
2752 switch( $sort )
2753 {
2754 case "author":
2755 {
2756 $sort_text = "ORDER BY A.ContentsWriterID";
2757 break;
2758 }
2759 case "name":
2760 {
2761 $sort_text = "ORDER BY A.Name";
2762 break;
2763 }
2764 case "category":
2765 {
2766 $sort_text = "ORDER BY C.Name";
2767 break;
2768 }
2769 default:
2770 case "published":
2771 {
2772 $sort_text = "ORDER BY A.Published DESC";
2773 break;
2774 }
2775 }
2776 }
2777
2778 $user =& eZUser::currentUser();
2779 $currentUserSQL = "";
2780 $groupSQL = "";
2781 $usePermission = true;
2782 if ( $user )
2783 {
2784 $groups =& $user->groups( false );
2785
2786 foreach ( $groups as $group )
2787 {
2788 $groupSQL .= " ( P.GroupID='$group' AND CP.GroupID='$group' ) OR
2789 ( P.GroupID='$group' AND CP.GroupID='-1' ) OR
2790 ( P.GroupID='-1' AND CP.GroupID='$group' ) OR
2791 ";
2792 }
2793 $currentUserID = $user->id();
2794 $currentUserSQL = "A.AuthorID=$currentUserID OR";
2795
2796 if ( $user->hasRootAccess() )
2797 $usePermission = false;
2798 }
2799 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL P.GroupID='-1' AND CP.GroupID='-1' ) AND P.ReadPermission='1' AND CP.ReadPermission='1' ) ) ";
2800
2801 $query = "SELECT A.ID, A.Name, Author.Name as AuthorName, A.Published, C.ID as CategoryID, C.Name as CategoryName
2802 FROM
2803 eZArticle_Article AS A,
2804 eZArticle_Category as C,
2805 eZArticle_ArticleCategoryDefinition as ACL,
2806 eZArticle_ArticlePermission AS P,
2807 eZArticle_CategoryPermission AS CP,
2808 eZUser_Author as Author
2809 WHERE $loggedInSQL AND A.ID=ACL.ArticleID AND C.ID=ACL.CategoryID AND A.ContentsWriterID=Author.ID AND
2810 IsPublished='1' AND ContentsWriterID='$authorid' AND
2811 CP.ObjectID=ACL.CategoryID AND
2812 A.ID=P.ObjectID GROUP BY A.ID $sort_text ";
2813
2814 $db =& eZDB::globalDatabase();
2815 $db->array_query( $qry_array, $query, array( "Limit" => $limit, "Offset" => $offset ) );
2816
2817 return $qry_array;
2818 }
2819
2823 static public function authorArticleCount( $authorid )
2824 {
2825 $user =& eZUser::currentUser();
2826 $currentUserSQL = "";
2827 $groupSQL = "";
2828 $usePermission = true;
2829 if ( $user )
2830 {
2831 $groups =& $user->groups( false );
2832
2833 foreach ( $groups as $group )
2834 {
2835 $groupSQL .= " ( P.GroupID='$group' AND CP.GroupID='$group' ) OR
2836 ( P.GroupID='$group' AND CP.GroupID='-1' ) OR
2837 ( P.GroupID='-1' AND CP.GroupID='$group' ) OR
2838 ";
2839 }
2840 $currentUserID = $user->id();
2841 $currentUserSQL = "A.AuthorID=$currentUserID OR";
2842
2843 if ( $user->hasRootAccess() )
2844 $usePermission = false;
2845 }
2846 $loggedInSQL = "( $currentUserSQL ( ( $groupSQL P.GroupID='-1' AND CP.GroupID='-1' ) AND P.ReadPermission='1' AND CP.ReadPermission='1' ) ) ";
2847
2848 $query = "SELECT count( DISTINCT A.ID ) AS Count
2849 FROM eZArticle_Article AS A,
2850 eZArticle_ArticleCategoryDefinition AS Def,
2851 eZArticle_ArticlePermission AS P,
2852 eZArticle_CategoryPermission AS CP,
2853 eZUser_Author as Author
2854 WHERE
2855 $loggedInSQL AND CP.ObjectID=Def.CategoryID AND A.ID=P.ObjectID AND A.ID=Def.ArticleID AND
2856 A.ContentsWriterID=Author.ID AND A.IsPublished='1' AND A.ContentsWriterID='$authorid'";
2857
2858 $db =& eZDB::globalDatabase();
2859 $db->array_query( $qry_array, $query );
2860
2861 return (int)$qry_array[0][$db->fieldName("Count")];
2862 }
2863
2867 function addLog( $message, $user = false )
2868 {
2869 $db =& eZDB::globalDatabase();
2870
2871 if ( !$user )
2872 $user =& eZUser::currentUser();
2873 $userID = $user->id();
2874
2875 $db->begin( );
2876
2877 $db->lock( "eZArticle_Log" );
2878
2879 $nextID = $db->nextID( "eZArticle_Log", "ID" );
2880
2881 $timeStamp =& (new eZDateTime())->timeStamp( true );
2882
2883 $query = "INSERT INTO eZArticle_Log
2884 ( ID, ArticleID, Created, Message, UserID )
2885 VALUES
2886 ( '$nextID',
2887 '$this->ID',
2888 '$timeStamp',
2889 '$message',
2890 '$userID' )";
2891
2892 $res = $db->query( $query );
2893
2894 $db->unlock();
2895
2896 if ( $res == false )
2897 $db->rollback( );
2898 else
2899 $db->commit();
2900 }
2901
2905 function deleteForms()
2906 {
2907 $db =& eZDB::globalDatabase();
2908
2909 $ArticleID = $this->ID;
2910
2911 $query = "DELETE FROM eZArticle_ArticleFormDict
2912 WHERE ArticleID=$ArticleID
2913 ";
2914 $db->query( $query );
2915 }
2916
2917
2921 function addForm( $form )
2922 {
2923 $db =& eZDB::globalDatabase();
2924
2925 if( is_a( $form, "eZForm" ) )
2926 {
2927 $ArticleID = $this->ID;
2928 $FormID = $form->id();
2929
2930 $db->begin( );
2931
2932 $db->lock( "eZArticle_ArticleFormDict" );
2933
2934 $nextID = $db->nextID( "eZArticle_ArticleFormDict", "ID" );
2935
2936 $query = "INSERT INTO eZArticle_ArticleFormDict
2937 ( ID, ArticleID, FormID )
2938 VALUES ( '$nextID', '$ArticleID', '$FormID' )
2939 ";
2940 $res = $db->query( $query );
2941
2942 $db->unlock();
2943
2944 if ( $res == false )
2945 $db->rollback( );
2946 else
2947 $db->commit();
2948
2949 }
2950 }
2951
2955 function forms( $as_object = true)
2956 {
2957 $db =& eZDB::globalDatabase();
2958
2959 // include_once( "ezform/classes/ezform.php" );
2960
2961 $ArticleID = $this->ID;
2962
2963 $return_array = array();
2964
2965 $query = "SELECT FormID FROM eZArticle_ArticleFormDict
2966 WHERE ArticleID=$ArticleID
2967 ";
2968
2969 $db->array_query( $ret_array, $query );
2970 $count = count( $ret_array );
2971 for( $i = 0; $i < $count; $i++ )
2972 {
2973 $id = $ret_array[$i][$db->fieldName("FormID")];
2974 $return_array[] = $as_object ? new eZForm( $id ) : $id;
2975 }
2976 return $return_array;
2977 }
2978
2984 function logMessages( )
2985 {
2986 $db =& eZDB::globalDatabase();
2987 $ret = array();
2988
2989 $query = "SELECT * FROM eZArticle_Log
2990 WHERE ArticleID='$this->ID'
2991 ORDER BY Created
2992 ";
2993
2994
2995 $db->array_query( $ret_array, $query );
2996 foreach( $ret_array as $log )
2997 {
2998 $ret[] = array( "Created" => $log[$db->fieldName( "Created" )], "UserID" => $log[$db->fieldName( "UserID" )], "Message" => $log[$db->fieldName( "Message" )] );
2999 }
3000 return $ret;
3001 }
3002
3008 function &getAll( )
3009 {
3010 $db =& eZDB::globalDatabase();
3011
3012 $returnArray = array();
3013 $articleArray = array();
3014
3015 // $db->array_query( $articleArray, "SELECT * FROM eZArticle_Article" );
3016
3017 $db->array_query( $articleArray, "SELECT ID
3018 FROM eZArticle_Article
3019 " );
3020
3021 for ( $i=0; $i < count($articleArray); $i++ )
3022 {
3023 $returnArray[$i] = new eZArticle( $articleArray[$i][$db->fieldName("ID")] );
3024 }
3025
3026 return $returnArray;
3027 }
3028
3034 function &getAllValid( $isPublished=false )
3035 {
3036 $db =& eZDB::globalDatabase();
3037
3038 $returnArray = array();
3039 $articleArray = array();
3040
3041 if ( !$isPublished )
3042 $published = " IsPublished='0' ";
3043 else
3044 $published = " IsPublished='1' ";
3045
3046 $now =& (new eZDateTime())->timeStamp( true );
3047
3048 $db->array_query( $articleArray, "SELECT *
3049 FROM eZArticle_Article
3050 WHERE $published
3051 AND ( StartDate !='0' AND StartDate <= $now )
3052 AND ( StopDate ='0' OR StopDate >= $now )
3053 ORDER BY ID
3054 " );
3055
3056 for ( $i=0; $i < count($articleArray); $i++ )
3057 {
3058 $returnArray[$i] = new eZArticle( $articleArray[$i] );
3059 }
3060
3061 return $returnArray;
3062 }
3063
3068 function sendPendingMail()
3069 {
3070 $ini =& eZINI::instance( 'site.ini' );
3071 $Language = $ini->variable( "eZArticleMain", "Language" );
3072 $adminSiteURL = $ini->variable( "site", "AdminSiteURL" );
3073 $index = $ini->Index;
3074 $wwwDir = $ini->WWWDir;
3075 global $HTTP_HOST;
3076
3077 $definition = $this->categoryDefinition();
3078
3079 $editorGroup = $definition->editorGroup();
3080
3081
3082 $mailTemplate = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
3083 "kernel/ezarticle/admin/intl", $Language, "pendingmail.php" );
3084
3085 $mailTemplate->set_file( "pending_mail_tpl", "pendingmail.tpl" );
3086 $mailTemplate->setAllStrings();
3087
3088
3089 $mail = new eZMail();
3090
3091 $author = $this->contentsWriter();
3092 $authorEmail = $author->email();
3093 $name = $author->name();
3094
3095 $mailTemplate->set_var( "author", $name . " " . $authorEmail );
3096 $mailTemplate->set_var( "url", "http://" . $HTTP_HOST . $wwwDir . $index .
3097 "/article/articlepreview/" . $this->ID . "/" );
3098 $mailBody = $mailTemplate->parse( "dummy", "pending_mail_tpl" );
3099 $mail->setBody( $mailBody );
3100
3101 $mail->setFrom( $authorEmail );
3102
3103 $users = $editorGroup->users();
3104 foreach ( $users as $userItem )
3105 {
3106 $mail->setTo( $userItem->email() );
3107 $mail->send();
3108 }
3109 }
3110
3116 function &getAllUnValid( $isPublished=true )
3117 {
3118 $db =& eZDB::globalDatabase();
3119
3120 $returnArray = array();
3121 $articleArray = array();
3122
3123 if ( !$isPublished )
3124 $published = " IsPublished='0' ";
3125 else
3126 $published = " IsPublished='1' ";
3127
3128 $now =& (new eZDateTime())->timeStamp( true );
3129
3130 $db->array_query( $articleArray, "SELECT *
3131 FROM eZArticle_Article
3132 WHERE $published
3133 AND ( StopDate !='0')
3134 AND StopDate <= $now
3135 ORDER BY ID
3136 " );
3137
3138 for ( $i=0; $i < count($articleArray); $i++ )
3139 {
3140 $returnArray[$i] = new eZArticle( $articleArray[$i] );
3141 }
3142
3143 return $returnArray;
3144 }
3145
3146
3147 var $ID;
3148 var $AuthorID;
3149 var $ContentsWriterID;
3150 var $Name;
3151 var $Contents;
3152 var $LinkText;
3153 var $Modified;
3154 var $Created;
3155 var $Published;
3156 // override publising date
3157 var $PublishedOverride;
3158 var $Keywords;
3159 var $Discuss;
3160 var $TopicID;
3161 var $StartDate;
3162 var $StopDate;
3163 var $ImportID;
3164
3165 // tell Exponential Basic to show the article to the public
3166 var $IsPublished;
3167
3168 // variable for storing the number of pages in the article.
3169 var $PageCount;
3170
3171 // php8
3172 var $AuthorText;
3173 var $AuthorEmail;
3174
3175 }
3176
3177 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$i
$i
Definition: admin/adlist.php:91
$topic
foreach( $authorArray as $author) $topic
Definition: admin/articleedit.php:852
$group
$group
Definition: admin/articleedit.php:799
$author
$author
Definition: admin/articleedit.php:834
$articleCount
$articleCount
Definition: admin/articlelist.php:456
$forum
$forum
Definition: admin/forumlist.php:50
$message
$message
Definition: admin/message.php:51
$userID
else $userID
Definition: appointmentedit.php:121
$dateTime
$dateTime
Definition: authorview.php:77
$date
$date
Definition: bugpreview.php:66
eZArticleAttribute
Definition: ezarticleattribute.php:49
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleType
Definition: ezarticletype.php:46
eZArticle
Definition: ezarticle.php:82
eZArticle\$Created
$Created
Definition: ezarticle.php:3154
eZArticle\files
files( $as_object=true)
Definition: ezarticle.php:1739
eZArticle\$IsPublished
$IsPublished
Definition: ezarticle.php:3166
eZArticle\deleteMedia
deleteMedia( $value)
Definition: ezarticle.php:1645
eZArticle\articleCount
articleCount( $fetchNonPublished=true, $excludeFromSearch=false)
Definition: ezarticle.php:2236
eZArticle\$Published
$Published
Definition: ezarticle.php:3155
eZArticle\media
media( $asObject=true)
Definition: ezarticle.php:1664
eZArticle\$Modified
$Modified
Definition: ezarticle.php:3153
eZArticle\deleteAttributesByType
deleteAttributesByType( $type)
Definition: ezarticle.php:1798
eZArticle\__construct
__construct( $id="")
Definition: ezarticle.php:89
eZArticle\modified
& modified()
Definition: ezarticle.php:578
eZArticle\setIsPublished
setIsPublished( $value, $user=false, $as_script=false)
Definition: ezarticle.php:1251
eZArticle\setStartDate
setStartDate(&$date)
Definition: ezarticle.php:1004
eZArticle\keywords
keywords()
Definition: ezarticle.php:589
eZArticle\pageCount
& pageCount()
Definition: ezarticle.php:555
eZArticle\$Keywords
$Keywords
Definition: ezarticle.php:3158
eZArticle\$Contents
$Contents
Definition: ezarticle.php:3151
eZArticle\logMessages
logMessages()
Definition: ezarticle.php:2984
eZArticle\deleteAttribute
deleteAttribute( $value)
Definition: ezarticle.php:1760
eZArticle\authorEmail
& authorEmail( $asHTML=true)
Definition: ezarticle.php:520
eZArticle\setManualKeywords
setManualKeywords( $keywords, $toLower=true)
Definition: ezarticle.php:898
eZArticle\getAllUnValid
& getAllUnValid( $isPublished=true)
Definition: ezarticle.php:3116
eZArticle\addFile
addFile( $value)
Definition: ezarticle.php:1686
eZArticle\stopDate
& stopDate( $as_object=true)
Definition: ezarticle.php:657
eZArticle\$AuthorEmail
$AuthorEmail
Definition: ezarticle.php:3173
eZArticle\contentsWriter
contentsWriter( $returnObject=true)
Definition: ezarticle.php:1127
eZArticle\topic
topic( $as_object=true)
Definition: ezarticle.php:1149
eZArticle\searchTitle
& searchTitle(&$queryText, $fetchPublished=false, &$SearchTotalCount=false, $categoryID=false)
Definition: ezarticle.php:2193
eZArticle\$AuthorText
$AuthorText
Definition: ezarticle.php:3172
eZArticle\setKeywords
setKeywords( $keywords)
Definition: ezarticle.php:739
eZArticle\setCategoryDefinition
setCategoryDefinition( $value)
Definition: ezarticle.php:2472
eZArticle\id
id()
Definition: ezarticle.php:467
eZArticle\getByImportID
static & getByImportID( $name)
Definition: ezarticle.php:396
eZArticle\setTopic
setTopic( $topic)
Definition: ezarticle.php:1139
eZArticle\setAuthorText
setAuthorText( $value)
Definition: ezarticle.php:696
eZArticle\isPublished
isPublished()
Definition: ezarticle.php:625
eZArticle\$ContentsWriterID
$ContentsWriterID
Definition: ezarticle.php:3149
eZArticle\searchByShortContent
static & searchByShortContent( $short_content, $keywords, $offset=0, $max=-1, $as_object=true)
Definition: ezarticle.php:1159
eZArticle\forms
forms( $as_object=true)
Definition: ezarticle.php:2955
eZArticle\thumbnailImage
thumbnailImage( $as_object=true)
Definition: ezarticle.php:1582
eZArticle\$StopDate
$StopDate
Definition: ezarticle.php:3162
eZArticle\author
& author( $as_object=true)
Definition: ezarticle.php:543
eZArticle\$StartDate
$StartDate
Definition: ezarticle.php:3161
eZArticle\authorText
& authorText( $asHTML=true)
Definition: ezarticle.php:508
eZArticle\authorArticleList
static authorArticleList( $authorid, $offset=0, $limit=-1, $sort=false)
Definition: ezarticle.php:2747
eZArticle\$Discuss
$Discuss
Definition: ezarticle.php:3159
eZArticle\moveImageUp
moveImageUp( $id)
Definition: ezarticle.php:1448
eZArticle\articles
& articles( $sortMode="time", $fetchNonPublished=true, $offset=0, $limit=50)
Definition: ezarticle.php:2352
eZArticle\$Name
$Name
Definition: ezarticle.php:3150
eZArticle\setLinkText
setLinkText( $value)
Definition: ezarticle.php:712
eZArticle\categoryDefinition
categoryDefinition( $as_object=true)
Definition: ezarticle.php:2512
eZArticle\published
& published()
Definition: ezarticle.php:614
eZArticle\getAll
& getAll()
Definition: ezarticle.php:3008
eZArticle\$PageCount
$PageCount
Definition: ezarticle.php:3169
eZArticle\getAllValid
& getAllValid( $isPublished=false)
Definition: ezarticle.php:3034
eZArticle\isAuthor
static isAuthor( $user, $articleID)
Definition: ezarticle.php:2672
eZArticle\startDate
& startDate( $as_object=true)
Definition: ezarticle.php:642
eZArticle\created
& created()
Definition: ezarticle.php:565
eZArticle\$ID
$ID
Definition: ezarticle.php:3147
eZArticle\setAuthor
setAuthor( $user)
Definition: ezarticle.php:720
eZArticle\manualKeywords
& manualKeywords( $as_array=false)
Definition: ezarticle.php:1043
eZArticle\setDiscuss
setDiscuss( $discuss)
Definition: ezarticle.php:887
eZArticle\attributes
attributes( $as_object=true)
Definition: ezarticle.php:1775
eZArticle\categoryDefinitionStatic
static categoryDefinitionStatic( $id)
Definition: ezarticle.php:2541
eZArticle\GetCategory
GetCategory( $articleSectionID=0)
Definition: ezarticle.php:2558
eZArticle\setName
setName( $value)
Definition: ezarticle.php:672
eZArticle\hasType
hasType( $type)
Definition: ezarticle.php:1849
eZArticle\createForum
createForum()
Definition: ezarticle.php:2600
eZArticle\$TopicID
$TopicID
Definition: ezarticle.php:3160
eZArticle\setPageCount
setPageCount( $value)
Definition: ezarticle.php:731
eZArticle\images
images( $asObject=true, $OrderBy="Created")
Definition: ezarticle.php:1408
eZArticle\manualKeywordIndex
static & manualKeywordIndex( $firstLetter=false)
Definition: ezarticle.php:1064
eZArticle\removeFromCategories
removeFromCategories()
Definition: ezarticle.php:1325
eZArticle\setImportID
setImportID( $value)
Definition: ezarticle.php:680
eZArticle\setStopDate
setStopDate(&$date)
Definition: ezarticle.php:1031
eZArticle\keywordFirstLetters
static & keywordFirstLetters()
Definition: ezarticle.php:982
eZArticle\authorList
static authorList( $offset=0, $limit=-1, $sort=false)
Definition: ezarticle.php:2710
eZArticle\addLog
addLog( $message, $user=false)
Definition: ezarticle.php:2867
eZArticle\setThumbnailImage
setThumbnailImage( $image)
Definition: ezarticle.php:1521
eZArticle\createIndex
createIndex()
Definition: ezarticle.php:753
eZArticle\addForm
addForm( $form)
Definition: ezarticle.php:2921
eZArticle\contents
& contents()
Definition: ezarticle.php:498
eZArticle\deleteImage
deleteImage( $value)
Definition: ezarticle.php:1389
eZArticle\deleteFile
deleteFile( $value)
Definition: ezarticle.php:1722
eZArticle\sendPendingMail
sendPendingMail()
Definition: ezarticle.php:3068
eZArticle\articleIDFromForum
static articleIDFromForum( $ForumID)
Definition: ezarticle.php:2689
eZArticle\moveImageDown
moveImageDown( $id)
Definition: ezarticle.php:1484
eZArticle\setContentsWriter
setContentsWriter( $author)
Definition: ezarticle.php:1116
eZArticle\$PublishedOverride
$PublishedOverride
Definition: ezarticle.php:3157
eZArticle\categories
categories( $as_object=true)
Definition: ezarticle.php:1297
eZArticle\addMedia
addMedia( $value)
Definition: ezarticle.php:1609
eZArticle\setAuthorEmail
setAuthorEmail( $value)
Definition: ezarticle.php:704
eZArticle\discuss
discuss()
Definition: ezarticle.php:598
eZArticle\deleteForms
deleteForms()
Definition: ezarticle.php:2905
eZArticle\forum
forum( $as_object=true)
Definition: ezarticle.php:2608
eZArticle\types
types( $as_object=true)
Definition: ezarticle.php:1828
eZArticle\name
name( $asHTML=true)
Definition: ezarticle.php:475
eZArticle\fill
fill( $article_array)
Definition: ezarticle.php:340
eZArticle\$LinkText
$LinkText
Definition: ezarticle.php:3152
eZArticle\$ImportID
$ImportID
Definition: ezarticle.php:3163
eZArticle\store
store()
Definition: ezarticle.php:114
eZArticle\existsInCategory
existsInCategory( $category)
Definition: ezarticle.php:1875
eZArticle\search
& search(&$queryText, $sortMode=time, $fetchPublished=false, $offset=0, $limit=10, $params=array(), &$SearchTotalCount=false)
Definition: ezarticle.php:1912
eZArticle\$AuthorID
$AuthorID
Definition: ezarticle.php:3148
eZArticle\authorArticleCount
static authorArticleCount( $authorid)
Definition: ezarticle.php:2823
eZArticle\importID
& importID()
Definition: ezarticle.php:488
eZArticle\getByName
static & getByName( $name)
Definition: ezarticle.php:370
eZArticle\setContents
setContents( $value)
Definition: ezarticle.php:688
eZArticle\addImage
addImage( $value, $placement=false)
Definition: ezarticle.php:1335
eZArticle\linkText
& linkText( $asHTML=true)
Definition: ezarticle.php:533
eZAuthor
Definition: ezauthor.php:40
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZForm
Definition: ezform.php:42
eZForum
Definition: ezforum.php:44
eZImage
Definition: ezimage.php:95
eZMail
Definition: ezmail.php:57
eZMedia
Definition: ezmedia.php:65
eZQuery
Definition: ezquery.php:54
eZTemplate
Definition: eztemplate.php:107
eZTextTool\fixhtmlentities
static fixhtmlentities( $string)
Definition: eztexttool.php:156
eZTopic
Definition: eztopic.php:41
eZUserGroup
Definition: ezusergroup.php:66
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZVirtualFile
Definition: ezvirtualfile.php:42
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$type
$type
Definition: classes/admin/linkselect.php:220
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$ArticleID
$ArticleID
Definition: export.php:48
$db
$db
Definition: ezarticle/user/authorlist.php:53
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$now
$now
Definition: ezcalendar/user/dayview.php:401
$fileList
$fileList
Definition: ezfilemanager/admin/browse.php:163
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$index
$index
Definition: ezforum/user/messageedit.php:36
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$imageList
$imageList
Definition: ezimagecatalogue/admin/unassigned.php:96
$sort
$sort
Definition: ezmail/user/maillist.php:172
$users
$users
Definition: ezmessage/admin/messageedit.php:138
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$form
$form
Definition: formedit.php:46
$count
$count
Definition: onlinetypelist.php:108
$RequireUserLogin
$RequireUserLogin
Definition: productpreview.php:51
$categoryID
else $categoryID
Definition: productview.php:66
$OrderBy
$OrderBy
Definition: reciverpopup.php:21
$wwwDir
$wwwDir
Definition: singlelist.php:33
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$category_array
$category_array
Definition: todoedit.php:604
$currentUserID
$currentUserID
Definition: todolist.php:128
$user
$user
Definition: user/adlist.php:39
$articleID
if( $Action=="New") $articleID
Definition: user/articleedit.php:269
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.