Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

admin/articleedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: articleedit.php 9526 2002-05-14 06:52:21Z bf $
5 //
6 // Created on: <18-Oct-2000 15:04:39 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlocale.php" );
31 // include_once( "classes/ezcachefile.php" );
32
33 // include_once( "ezuser/classes/ezuser.php" );
34 // include_once( "ezuser/classes/ezobjectpermission.php" );
35 // include_once( "ezuser/classes/ezauthor.php" );
36 // include_once( "classes/ezhttptool.php" );
37
38 // include_once( "ezarticle/classes/ezarticlecategory.php" );
39 // include_once( "ezarticle/classes/ezarticle.php" );
40 // include_once( "ezarticle/classes/eztopic.php" );
41 // include_once( "ezarticle/classes/ezarticlegenerator.php" );
42 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
43
44 // include_once( "ezbulkmail/classes/ezbulkmail.php" );
45 // include_once( "ezbulkmail/classes/ezbulkmailcategory.php" );
46
47 // include_once( "ezarticle/classes/ezarticletool.php" );
48
49 // include_once( "ezxml/classes/ezxml.php" );
50
51 $ini =& eZINI::instance( 'site.ini' );
52
53 $CategoryID = isset($_POST["CategoryID"]) ? $_POST["CategoryID"] : false;
54
55 // article published from preview
56 if ( isset( $PublishArticle ) )
57 {
58 $article = new eZArticle();
59
60 if ( $article->get( $ArticleID ) )
61 {
62 $article->setIsPublished( true );
63 $article->store();
64 }
65
66 $category =& $article->categoryDefinition( );
67
68 if ( $category )
69 {
70 $categoryID = $category->id();
71 }
72
73 eZHTTPTool::header( "Location: /article/archive/$categoryID/" );
74 exit();
75 }
76
77 if ( isset( $Action ) && $Action == "Cancel" )
78 {
79 $article = new eZArticle( $ArticleID );
80
81 $category = $article->categoryDefinition( );
82
83 if ( $category )
84 {
85 $categoryID = $category->id();
86 }
87
88 eZHTTPTool::header( "Location: /article/archive/$categoryID/" );
89 exit();
90 }
91
92 // update an existing article in the database
93 if ( isset( $Action ) && $Action == "Update" || ( isset( $Action ) && $Action == "Insert" ) )
94 {
95 $sendNotification = false;
96 $article = new eZArticle( );
97
98 if ( ( isset( $Action ) && $Action == "Insert" ) or ( $article->get( $ArticleID ) == true ) )
99 {
100 if ( isset( $Action ) && $Action == "Update" )
101 {
102 $article = new eZArticle( $ArticleID );
103 }
104 elseif ( isset( $Action ) && $Action == "Insert" )
105 {
106 $article = new eZArticle( );
107 $user =& eZUser::currentUser();
108 $article->setAuthor( $user );
109 }
110
111 $article->setName( $_POST['Name'] );
112
113 if ( trim( $_POST['NewAuthorName'] ) != "" )
114 {
115 $author = new eZAuthor();
116 $author->setName( $NewAuthorName );
117 $author->setEmail( $NewAuthorEmail );
118 $author->store();
119 $article->setContentsWriter( $author );
120 }
121 else
122 {
123 $author = new eZAuthor( $ContentsWriterID );
124 $article->setContentsWriter( $author );
125 }
126
127 $topic = new eZTopic( $TopicID );
128 $article->setTopic( $topic );
129
130 $generator = new eZArticleGenerator();
131
132 $contents = $generator->generateXML( $Contents );
133
134 $article->setContents( $contents );
135 $article->setPageCount( $generator->pageCount() );
136
137
138 $article->setAuthorText( $AuthorText );
139 $article->setAuthorEmail( $AuthorEmail );
140 $article->setLinkText( $LinkText );
141
142 if ( trim( $LogMessage ) != "" )
143 $article->addLog( $LogMessage );
144
145 if ( isset( $Discuss ) && $Discuss == "on" )
146 {
147 $article->setDiscuss( true );
148 }
149 else
150 $article->setDiscuss( false );
151
152 // check if the contents is parseable
153 if ( eZXML::domTree( $contents ) )
154 {
155 // to get ID
156 $article->store();
157
158 // add to categories
159 $category = new eZArticleCategory( $CategoryID );
160 $article->setCategoryDefinition( $category );
161
162 $iniVar = $ini->variable( "eZArticleMain", "LowerCaseManualKeywords" );
163
164 if ( $iniVar == "enabled" )
165 $toLower = true;
166 else
167 $toLower = false;
168
169 $article->setManualKeywords( $Keywords, $toLower );
170
171 $categoryArray = $article->categories();
172
173 if( !isset( $CategoryArray ) )
174 $CategoryArray = array();
175
176 // Calculate new and unused categories
177 $old_maincategory = $article->categoryDefinition();
178 $old_categories =& array_unique( array_merge( array( $old_maincategory->id() ),
179 $article->categories( false ) ) );
180
181 $new_categories = array_unique( array_merge( array( $CategoryID ), $CategoryArray ) );
182
183 $remove_categories = array_diff( $old_categories, $new_categories );
184 $add_categories = array_diff( $new_categories, $old_categories );
185
186 $categoryIDArray = array();
187
188 foreach ( $categoryArray as $cat )
189 {
190 $categoryIDArray[] = $cat->id();
191 }
192
193 // clear the cache files.
194 eZArticleTool::deleteCache( $ArticleID, $CategoryID, $old_categories );
195
196 foreach ( $remove_categories as $categoryItem )
197 {
198 eZArticleCategory::removeArticle( $article, $categoryItem );
199 }
200
201 // add to categories
202
203 $category = new eZArticleCategory( $CategoryID );
204
205 $category->addArticle( $article, $CategoryID );
206 $article->setCategoryDefinition( $category );
207
208 foreach ( $add_categories as $categoryItem )
209 {
210 eZArticleCategory::addArticle( $article, $categoryItem );
211 }
212
213 //EP: URL translation inside articles -------------------------
214
215 if ( isset( $UrltranslatorEnabled ) && $UrltranslatorEnabled )
216 {
217 $tmpCategory = $article->categoryDefinition();
218 $url1 = "/article/articleview/" . $article->id() . "/1/" . $tmpCategory->id();
219
220 // include_once( "ezurltranslator/classes/ezurltranslator.php" );
221 $urltranslator = new eZURLTranslator();
222 $urltranslator->getbydest ( $url1 );
223
224 if ( $Urltranslator )
225 {
226 $urltranslator->setSource( $Urltranslator );
227 $urltranslator->setDest( $url1 );
228 $urltranslator->store();
229 }
230 else
231 {
232 $urltranslator->delete();
233 }
234 }
235
236 //EP -------------------------------------------------------------
237
238 // Time publishing
239 if ( checkdate( (int)$StartMonth, (int)$StartDay, (int)$StartYear ) )
240 {
241 $startDate = new eZDateTime( $StartYear, $StartMonth, $StartDay, $StartHour, $StartMinute, 0 );
242 $article->setStartDate( $startDate );
243 }
244
245 if ( checkdate( (int)$StopMonth, (int)$StopDay, (int)$StopYear ) )
246 {
247 $stopDate = new eZDateTime( $StopYear, $StopMonth, $StopDay, $StopHour, $StopMinute, 0 );
248 $article->setStopDate( $stopDate );
249 }
250
251 eZObjectPermission::removePermissions( $article->id(), "article_article", 'w' );
252 if ( isset( $WriteGroupArray ) )
253 {
254 if ( $WriteGroupArray[0] == 0 )
255 {
256 eZObjectPermission::setPermission( -1, $article->id(), "article_article", 'w' );
257 }
258 else
259 {
260 foreach ( $WriteGroupArray as $groupID )
261 {
262 eZObjectPermission::setPermission( $groupID, $article->id(), "article_article", 'w' );
263 }
264 }
265 }
266 else
267 {
268 eZObjectPermission::removePermissions( $article->id(), "article_article", 'w' );
269 }
270
271 /* read access thingy */
272 eZObjectPermission::removePermissions( $article->id(), "article_article", 'r' );
273 if ( isset( $GroupArray ) )
274 {
275 if ( $GroupArray[0] == 0 )
276 {
277 eZObjectPermission::setPermission( -1, $article->id(), "article_article", 'r' );
278 }
279 else // some groups are selected.
280 {
281 foreach ( $GroupArray as $groupID )
282 {
283 eZObjectPermission::setPermission( $groupID, $article->id(), "article_article", 'r' );
284 }
285 }
286 }
287 else
288 {
289 eZObjectPermission::removePermissions( $article->id(), "article_article", 'r' );
290 }
291
292 // add check for publishing rights here
293 if ( $IsPublished == "on" )
294 {
295 // check if the article is published now
296 if ( $article->isPublished() == false )
297 {
298 $sendNotification = true;
299 }
300
301 $article->setIsPublished( true );
302 }
303 else
304 {
305 $article->setIsPublished( false );
306 }
307
308
309 // generate keywords
310 $contents = strip_tags( $contents );
311 $contents = preg_replace( "#\n#", "", $contents );
312 $contents_array =& preg_split( "/ /", $contents );
313 $contents_array = array_unique( $contents_array );
314
315 $keywords = "";
316 foreach ( $contents_array as $word )
317 {
318 $keywords .= $word . " ";
319 }
320
321 $article->setKeywords( $keywords );
322
323 $article->store();
324 $ArticleID = $article->id();
325
326 // clear the cache files.
327 eZArticleTool::deleteCache( $ArticleID, $CategoryID, $old_categories );
328
329 if ( $sendNotification )
330 eZArticleTool::notificationMessage( $article );
331
332 // Go to insert item..
333 if ( isset( $AddItem ) )
334 {
335 switch ( $ItemToAdd )
336 {
337 case "Image":
338 {
339 // add images
340 eZHTTPTool::header( "Location: /article/articleedit/imagelist/$ArticleID/" );
341 exit();
342 }
343 break;
344
345 case "Media":
346 {
347 // add media
348 eZHTTPTool::header( "Location: /article/articleedit/medialist/$ArticleID/" );
349 exit();
350 }
351 break;
352
353 case "File":
354 {
355 // add files
356 eZHTTPTool::header( "Location: /article/articleedit/filelist/$ArticleID/" );
357 exit();
358 }
359 break;
360
361 case "Attribute":
362 {
363 // add attributes
364 eZHTTPTool::header( "Location: /article/articleedit/attributelist/$ArticleID/" );
365 exit();
366 }
367 break;
368
369 case "Form":
370 {
371 // add form
372 eZHTTPTool::header( "Location: /article/articleedit/formlist/$ArticleID/" );
373 exit();
374 }
375 break;
376
377 // attribute
378 case "ModuleLinker":
379 {
380 eZHTTPTool::header( "Location: /article/articleedit/link/list/$ArticleID/" );
381 exit();
382 }
383 break;
384
385 }
386 }
387
388 // preview
389 if ( isset( $Preview ) )
390 {
391 eZHTTPTool::header( "Location: /article/articlepreview/$ArticleID/" );
392 exit();
393 }
394
395 // log history
396 if ( isset( $Log ) )
397 {
398 eZHTTPTool::header( "Location: /article/articlelog/$ArticleID/" );
399 exit();
400 }
401
402 // get the category to redirect to
403 $category = $article->categoryDefinition( );
404 $categoryID = $category->id();
405
406 if ( $article->isPublished() )
407 {
408 eZHTTPTool::header( "Location: /article/archive/$categoryID/" );
409 }
410 else
411 {
412 eZHTTPTool::header( "Location: /article/unpublished/$categoryID/" );
413 }
414 exit();
415 }
416 else
417 {
418 $invalidContents = $contents;
419
420 if ( $Action == "Insert" )
421 $Action = "New";
422 else
423 $Action = "Edit";
424
425 $ErrorParsing = true;
426 }
427 }
428 }
429 elseif ( isset( $Action ) && $Action == "New")
430 {
431 $Name = '';
432 $ContentsWriterID = false;
433 $Keywords = '';
434 $Contents = array();
435 $Contents[0] = false;
436 $Contents[1] = false;
437 $Contents[2] = false;
438 $Contents[3] = false;
439 $AuthorText = '';
440 $AuthorEmail = '';
441 $LinkText = '';
442 $StartDay = '';
443 $StartMonth = '';
444 $StartHour = '';
445 $StartMinute = '';
446 $StartYear = '';
447 $StopDay = '';
448 $StopMonth = '';
449 $StopMinute = '';
450 $StopYear = '';
451 $StopHour = '';
452 }
453 elseif ( isset( $Action ) && $Action == "Edit" )
454 {
455 if( !isset( $Name ) )
456 $Name = '';
457 if( !isset( $ContentsWriterID ) )
458 $ContentsWriterID = false;
459
460 if( !isset( $Keywords ) )
461 $Keywords = '';
462
463 if( !isset( $Contents[0] ) )
464 $Contents[0] = false;
465 if( !isset( $Contents[1] ) )
466 $Contents[1] = false;
467 if( !isset( $Contents[2] ) )
468 $Contents[2] = false;
469 if( !isset( $Contents[3] ) )
470 $Contents[3] = false;
471
472 if( !isset( $AuthorText ) )
473 $AuthorText = '';
474 if( !isset( $AuthorEmail ) )
475 $AuthorEmail = '';
476 if( !isset( $LinkText ) )
477 $LinkText = '';
478 if( !isset( $StartDay ) )
479 $StartDay = '';
480 if( !isset( $StartMonth ) )
481 $StartMonth = '';
482 if( !isset( $StartHour ) )
483 $StartHour = '';
484 if( !isset( $StartMinute ) )
485 $StartMinute = '';
486 if( !isset( $StartYear ) )
487 $StartYear = '';
488 if( !isset( $StopDay ) )
489 $StopDay = '';
490 if( !isset( $StopMonth ) )
491 $StopMonth = '';
492 if( !isset( $StopMinute ) )
493 $StopMinute = '';
494 if( !isset( $StopYear ) )
495 $StopYear = '';
496 if( !isset( $StopHour ) )
497 $StopHour = '';
498 }
499 $Language = $ini->variable( "eZArticleMain", "Language" );
500 $ShowModuleLinker = $ini->variable( "eZArticleMain", "ShowModuleLinker" ) == "true";
501
502 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
503 "kernel/ezarticle/admin/intl/", $Language, "articleedit.php" );
504
505 $t->setAllStrings();
506
507 $t->set_file( "article_edit_page_tpl", "articleedit.tpl" );
508
509 $t->set_block( "article_edit_page_tpl", "topic_item_tpl", "topic_item" );
510 $t->set_block( "article_edit_page_tpl", "value_tpl", "value" );
511 $t->set_block( "article_edit_page_tpl", "multiple_value_tpl", "multiple_value" );
512 $t->set_block( "article_edit_page_tpl", "category_owner_tpl", "category_owner" );
513 $t->set_block( "article_edit_page_tpl", "group_item_tpl", "group_item" );
514 $t->set_block( "article_edit_page_tpl", "publish_dates_tpl", "publish_dates" );
515 $t->set_block( "article_edit_page_tpl", "article_pending_tpl", "article_pending" );
516 $t->set_block( "article_edit_page_tpl", "author_pending_information_tpl", "author_pending_information" );
517 $t->set_block( "article_edit_page_tpl", "author_item_tpl", "author_item" );
518
519 $t->set_block( "publish_dates_tpl", "published_tpl", "published" );
520 $t->set_block( "publish_dates_tpl", "un_published_tpl", "un_published" );
521
522 $t->set_block( "article_edit_page_tpl", "error_message_tpl", "error_message" );
523 $t->set_block( "article_edit_page_tpl", "urltranslator_tpl", "urltranslator" );
524 $t->set_block( "article_edit_page_tpl", "module_linker_button_tpl", "module_linker_button" );
525
526 $Locale = new eZLocale( $Language );
527 if ( isset($_REQUEST['ErrorParsing']) )
528 {
529 $t->set_var( "article_invalid_contents", $invalidContents );
530 $t->parse( "error_message", "error_message_tpl" );
531 }
532 else
533 {
534 $t->set_var( "error_message", "" );
535 }
536
537 $t->set_var( "article_is_published", "" );
538 $t->set_var( "article_id", "" );
539 $t->set_var( "article_name", stripslashes( $Name ) );
540
541 //EP: URL translation : new article -------------------------------------------
542
543 if ( $ini->variable( "eZArticleMain", "AdminURLTranslator" ) == "enabled" )
544 {
545 $t->set_var( "article_url", "" );
546 $t->set_var( "article_urltranslator", "" );
547 $t->parse( "urltranslator", "urltranslator_tpl" );
548 }
549 else
550 {
551 $t->set_var( "article_url", "" );
552 $t->set_var( "intl-article_nourl", "" );
553 $t->set_var( "article_urltranslator", "" );
554 $t->set_var( "urltranslator", "" );
555 }
556 //EP --------------------------------------------------------------------------
557
558 $t->set_var( "article_keywords", stripslashes( $Keywords ) );
559 $t->set_var( "article_contents_0", stripslashes( $Contents[0] ) );
560 $t->set_var( "article_contents_1", stripslashes( $Contents[1] ) );
561 $t->set_var( "article_contents_2", stripslashes( $Contents[2] ) );
562 $t->set_var( "article_contents_3", stripslashes( $Contents[3] ) );
563 $t->set_var( "author_text", stripslashes( $AuthorText ) );
564 $t->set_var( "author_email", stripslashes( $AuthorEmail ) );
565 $t->set_var( "link_text", stripslashes( $LinkText ) );
566
567 $t->set_var( "start_day", stripslashes( $StartDay ) );
568 $t->set_var( "start_month", stripslashes( $StartMonth ) );
569 $t->set_var( "start_year", stripslashes( $StartYear ) );
570 $t->set_var( "start_hour", stripslashes( $StartHour ) );
571 $t->set_var( "start_minute", stripslashes( $StartMinute ) );
572 $t->set_var( "stop_day", stripslashes( $StopDay ) );
573 $t->set_var( "stop_month", stripslashes( $StopMonth ) );
574 $t->set_var( "stop_year", stripslashes( $StopYear ) );
575 $t->set_var( "stop_hour", stripslashes( $StopHour ) );
576 $t->set_var( "stop_minute", stripslashes( $StopMinute ) );
577
578 $t->set_var( "action_value", "insert" );
579 $t->set_var( "all_selected", "selected" );
580 $t->set_var( "all_write_selected", "selected" );
581 $writeGroupsID = array();
582 $readGroupsID = array();
583
584 if ( $Action == "New" )
585 {
586 $user =& eZUser::currentUser();
587 $t->set_var( "author_text", $user->firstName() . " " . $user->lastName() );
588 $article = new eZArticle();
589 }
590
591 $t->set_var( "author_pending_information", "" );
592 $t->set_var( "publish_dates", "" );
593 $t->set_var( "article_pending", "" );
594 if ( isset( $Action ) && $Action == "Edit" || $Action == "Insert" )
595 {
596 $article = new eZArticle();
597
598 if ( !$article->get( $ArticleID ) )
599 {
600 eZHTTPTool::header( "Location: /error/404/" );
601 exit();
602 }
603
604 $definition =& $article->categoryDefinition();
605
606
607 $t->set_var( "article_id", $ArticleID );
608
609 $pending = false;
610 if ( $article->isPublished() )
611 {
612 if ( $article->isPublished() == 2 )
613 {
614 $pending = true;
615 $t->parse( "article_pending", "article_pending_tpl" );
616 }
617 else
618 $t->set_var( "article_is_published", "checked" );
619 }
620 else
621 {
622 $t->set_var( "article_is_published", "" );
623 }
624
625 if ( $article->discuss() )
626 {
627 $t->set_var( "discuss_article", "checked" );
628 }
629 else
630 {
631 $t->set_var( "discuss_article", "" );
632 }
633
634 $startDate =& $article->startDate();
635 $stopDate =& $article->stopDate();
636
637 if ( $article->startDate( false ) != 0 )
638 {
639 $t->set_var( "start_day", "" );
640 $t->set_var( "start_month", "" );
641 $t->set_var( "start_year", "" );
642 $t->set_var( "start_hour", "" );
643 $t->set_var( "start_minute", "" );
644 if ( is_a( $startDate, "eZDateTime" ) )
645 {
646 $t->set_var( "start_day", $startDate->addZero( $startDate->day() ) );
647 $t->set_var( "start_month", $startDate->addZero( $startDate->month() ) );
648 $t->set_var( "start_year", $startDate->addZero( $startDate->year() ) );
649 $t->set_var( "start_hour", $startDate->addZero( $startDate->hour() ) );
650 $t->set_var( "start_minute", $startDate->addZero( $startDate->minute() ) );
651 }
652 }
653
654 if ( $article->stopDate( false ) != 0 )
655 {
656 $t->set_var( "stop_day", "" );
657 $t->set_var( "stop_month", "" );
658 $t->set_var( "stop_year", "" );
659 $t->set_var( "stop_hour", "" );
660 $t->set_var( "stop_minute", "" );
661
662 if ( is_a( $stopDate, "eZDateTime" ) )
663 {
664 $t->set_var( "stop_day", $startDate->addZero( $stopDate->day() ) );
665 $t->set_var( "stop_month", $startDate->addZero( $stopDate->month() ) );
666 $t->set_var( "stop_year", $startDate->addZero( $stopDate->year() ) );
667 $t->set_var( "stop_hour", $startDate->addZero( $stopDate->hour() ) );
668 $t->set_var( "stop_minute", $startDate->addZero( $stopDate->minute() ) );
669 }
670 }
671
672 if ( !isset( $_REQUEST['Name'] ) )
673 $t->set_var( "article_name", $article->name() );
674
675 $generator = new eZArticleGenerator();
676
677 $contentsArray = $generator->decodeXML( $article->contents() );
678 $Contents = array();
679 $i = 0;
680 foreach ( $contentsArray as $content )
681 {
682 if ( !isset( $Contents[$i] ) )
683 {
684 $Contents[$i] = htmlspecialchars( $content );
685 $t->set_var( "article_contents_$i", htmlspecialchars( $content ) );
686 }
687 $i++;
688 }
689
690 $ContentsCount = count( $Contents );
691
692 for( $i = $ContentsCount; $i <= 4; $i++ )
693 {
694 $Contents[$i] = false;
695 }
696
697
698 //EP: URL translation: article edit get translation
699
700 if ( $ini->variable( "eZArticleMain", "AdminURLTranslator" ) == "enabled" )
701 {
702
703 $category = $article->categoryDefinition();
704 $url1 = "/article/articleview/" . $article->id() . "/1/" . $category->id();
705 $t->set_var( "article_url", $url1 );
706 $t->set_var( "intl-article_nourl", "" );
707
708 // include_once( "ezurltranslator/classes/ezurltranslator.php" );
709 $urltranslator = new eZURLTranslator();
710 $urltranslator->getbydest ( $url1 );
711 $t->set_var( "article_urltranslator", $urltranslator->source() );
712
713 $t->parse( "urltranslator", "urltranslator_tpl" );
714 }
715
716 $t->set_var( "article_keywords", $article->manualKeywords() );
717
718 $AuthorText = $article->authorText();
719 $t->set_var( "author_text", $article->authorText() );
720 $AuthorEmail = $article->authorEmail();
721 $t->set_var( "author_email", $article->authorEmail() );
722
723 if ( $pending )
724 {
725 $t->parse( "author_pending_information", "author_pending_information_tpl" );
726 }
727 else
728 {
729 $t->set_var( "author_pending_information", "" );
730 }
731
732 $t->set_var( "link_text", $article->linkText() );
733
734 $t->set_var( "action_value", "update" );
735
736 $author = $article->contentsWriter();
737 $ContentsWriterID = $author->id();
738
739 $topic = $article->topic();
740 $TopicID = $topic->id();
741
742 $writeGroupsID = eZObjectPermission::getGroups( $ArticleID, "article_article", 'w' , false );
743 $readGroupsID = eZObjectPermission::getGroups( $ArticleID, "article_article", 'r', false );
744
745
746 if( $writeGroupsID[0] != -1 )
747 $t->set_var( "all_write_selected", "" );
748 if( $readGroupsID[0] != -1 )
749 $t->set_var( "all_selected", "" );
750 // dates
751 $published =& $article->published();
752 $created =& $article->created();
753 $modified =& $article->modified();
754 $t->set_var( "published_date", $Locale->format( $published ) );
755 $t->set_var( "created_date", $Locale->format( $created ) );
756 $t->set_var( "modified_date", $Locale->format( $modified ) );
757
758 if ( $article->isPublished() == true )
759 {
760 $t->parse( "published", "published_tpl" );
761 $t->set_var( "un_published", "" );
762 }
763 else
764 {
765 $t->parse( "un_published", "un_published_tpl" );
766 $t->set_var( "published", "" );
767 }
768
769 $t->parse( "publish_dates", "publish_dates_tpl" );
770
771 $t->set_var( "module_linker_button", "" );
772 if ( $ShowModuleLinker )
773 $t->parse( "module_linker_button", "module_linker_button_tpl" );
774 }
775
776 $t->set_var( "article_keywords", stripslashes( $Keywords ) );
777 $t->set_var( "article_contents_0", stripslashes( $Contents[0] ) );
778 $t->set_var( "article_contents_1", stripslashes( $Contents[1] ) );
779 $t->set_var( "article_contents_2", stripslashes( $Contents[2] ) );
780 $t->set_var( "article_contents_3", stripslashes( $Contents[3] ) );
781 $t->set_var( "author_text", stripslashes( $AuthorText ) );
782 $t->set_var( "author_email", stripslashes( $AuthorEmail ) );
783 $t->set_var( "link_text", stripslashes( $LinkText ) );
784
785 $t->set_var( "start_day", stripslashes( $StartDay ) );
786 $t->set_var( "start_month", stripslashes( $StartMonth ) );
787 $t->set_var( "start_year", stripslashes( $StartYear ) );
788 $t->set_var( "start_hour", stripslashes( $StartHour ) );
789 $t->set_var( "start_minute", stripslashes( $StartMinute ) );
790 $t->set_var( "stop_day", stripslashes( $StopDay ) );
791 $t->set_var( "stop_month", stripslashes( $StopMonth ) );
792 $t->set_var( "stop_year", stripslashes( $StopYear ) );
793 $t->set_var( "stop_hour", stripslashes( $StopHour ) );
794 $t->set_var( "stop_minute", stripslashes( $StopMinute ) );
795
796 if( isset( $Action ) && $Action == "New" )
797 $t->set_var( "action_value", "insert" );
798
799 $group = new eZUserGroup();
800 $groupList = $group->getAll();
801 $groupListIDs = array( "0" );
802 foreach( $groupList as $index => $group )
803 {
804 $groupListIDs[] = $group->id();
805 }
806
807 if( !isset( $readGroupsID[0] ) || $readGroupsID[0] == "-1" )
808 $groupListIDsSelection = 0;
809 else
810 $groupListIDsSelection = $readGroupsID[0];
811
812 if( !isset( $writeGroupsID[0] ) || $writeGroupsID[0] == "-1" )
813 $writeGroupsIDsSelection = 0;
814 else
815 $writeGroupsIDsSelection = $writeGroupsID[0];
816
817 if( $groupListIDsSelection == $groupListIDs[0] )
818 $t->set_var( "all_selected", "selected" );
819 else
820 $t->set_var( "all_selected", "" );
821
822 if( $writeGroupsIDsSelection == $groupListIDs[0] )
823 $t->set_var( "all_write_selected", "selected" );
824 else
825 $t->set_var( "all_write_selected", "" );
826
827 if( !isset( $writeGroupsID ) )
828 $writeGroupsID = array();
829
830 if( !isset( $readGroupsID ) )
831 $readGroupsID = array();
832
833 // author select
834 $author = new eZAuthor();
835 $authorArray = $author->getAll();
836 foreach ( $authorArray as $author )
837 {
838 if ( $ContentsWriterID == $author->id() )
839 {
840 $t->set_var( "selected", "selected" );
841 }
842 else
843 {
844 $t->set_var( "selected", "" );
845 }
846 $t->set_var( "author_id", $author->id() );
847 $t->set_var( "author_name", $author->name() );
848 $t->parse( "author_item", "author_item_tpl", true );
849 }
850
851 // topic select
852 $topic = new eZTopic();
853 $topicArray = $topic->getAll();
854 foreach ( $topicArray as $topic )
855 {
856 if ( $TopicID == $topic->id() )
857 {
858 $t->set_var( "selected", "selected" );
859 }
860 else
861 {
862 $t->set_var( "selected", "" );
863 }
864 $t->set_var( "topic_id", $topic->id() );
865 $t->set_var( "topic_name", $topic->name() );
866 $t->parse( "topic_item", "topic_item_tpl", true );
867 }
868
869 // category select
870 $category = new eZArticleCategory();
871 $categoryArray = $category->getAll( );
872
873
874 $tree = new eZArticleCategory();
875 $treeArray =& $tree->getTree();
876 $user =& eZUser::currentUser();
877
878 $catCount = count( $treeArray );
879 $t->set_var( "num_select_categories", min( $catCount, 10 ) );
880
881 foreach ( $treeArray as $catItem )
882 {
883 if ( eZObjectPermission::hasPermission( $catItem[0]->id(), "article_category", 'w', $user ) == true ||
884 eZArticleCategory::isOwner( eZUser::currentUser(), $catItem[0]->id() ) )
885 {
886 if ( $Action == "Edit" )
887 {
888 $defCat = $article->categoryDefinition( );
889
890 if ( is_a( $defCat, "eZArticleCategory" ) )
891 {
892 if ( $article->existsInCategory( $catItem[0] ) && $defCat->id() != $catItem[0]->id() )
893 {
894 $t->set_var( "multiple_selected", "selected" );
895 }
896 else
897 {
898 $t->set_var( "multiple_selected", "" );
899 }
900 }
901 else
902 {
903 $t->set_var( "selected", "" );
904 }
905
906 if ( is_a( $defCat, "eZArticleCategory" ) )
907 {
908 if ( $defCat->id() == $catItem[0]->id() )
909 {
910 $t->set_var( "selected", "selected" );
911 }
912 else
913 {
914 $t->set_var( "selected", "" );
915 }
916 }
917 else
918 {
919 $t->set_var( "selected", "" );
920 }
921 }
922 else
923 {
924 $t->set_var( "selected", "" );
925 $t->set_var( "multiple_selected", "" );
926 }
927
928 $t->set_var( "option_value", $catItem[0]->id() );
929 $t->set_var( "option_name", $catItem[0]->name() );
930
931 if ( $catItem[1] > 1 )
932 $t->set_var( "option_level", str_repeat( "&nbsp;&nbsp;", $catItem[1] ) );
933 else
934 $t->set_var( "option_level", "" );
935
936 $t->parse( "value", "value_tpl", true );
937 $t->parse( "multiple_value", "multiple_value_tpl", true );
938 }
939 }
940
941 // group selector
942 $group = new eZUserGroup();
943 $groupList = $group->getAll();
944
945 $t->set_var( "selected", "" );
946 foreach ( $groupList as $groupItem )
947 {
948 //for the group owner selector */
949 $t->set_var( "module_owner_id", $groupItem->id() );
950 $t->set_var( "module_owner_name", $groupItem->name() );
951
952 if ( in_array( $groupItem->id(), $writeGroupsID ) )
953 {
954 $t->set_var("is_selected", "selected");
955 }
956 else
957 $t->set_var( "is_selected", "" );
958
959 $t->parse( "category_owner", "category_owner_tpl", true );
960
961 // for the read access groups selector */
962 $t->set_var( "group_name", $groupItem->name() );
963 $t->set_var( "group_id", $groupItem->id() );
964 if ( in_array( $groupItem->id(), $readGroupsID ) )
965 $t->set_var( "selected", "selected" );
966 else
967 $t->set_var( "selected", "" );
968
969
970 $t->parse( "group_item", "group_item_tpl", true );
971 }
972
973 if ( $ShowModuleLinker )
974 $t->parse( "module_linker_button", "module_linker_button_tpl" );
975
976 $t->pparse( "output", "article_edit_page_tpl" );
977
978 ?>
$i
$i
Definition: admin/adlist.php:91
$writeGroupsID
$writeGroupsID
Definition: admin/articleedit.php:581
$writeGroupsIDsSelection
else $writeGroupsIDsSelection
Definition: admin/articleedit.php:815
$category
foreach( $topicArray as $topic) $category
Definition: admin/articleedit.php:870
$groupListIDsSelection
else $groupListIDsSelection
Definition: admin/articleedit.php:810
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$t
$t
Definition: admin/articleedit.php:502
$treeArray
$treeArray
Definition: admin/articleedit.php:875
$user
$user
Definition: admin/articleedit.php:876
$groupListIDs
$groupListIDs
Definition: admin/articleedit.php:801
$tree
$tree
Definition: admin/articleedit.php:874
$topic
foreach( $authorArray as $author) $topic
Definition: admin/articleedit.php:852
$authorArray
$authorArray
Definition: admin/articleedit.php:835
$topicArray
$topicArray
Definition: admin/articleedit.php:853
$Locale
$Locale
Definition: admin/articleedit.php:526
$groupList
$groupList
Definition: admin/articleedit.php:800
$ini
$ini
Definition: admin/articleedit.php:51
$catCount
$catCount
Definition: admin/articleedit.php:878
$group
$group
Definition: admin/articleedit.php:799
$author
$author
Definition: admin/articleedit.php:834
$categoryArray
$categoryArray
Definition: admin/articleedit.php:871
$Language
if(isset( $PublishArticle)) if(isset( $Action) && $Action=="Cancel") if(isset( $Action) && $Action=="Update"||(isset( $Action) && $Action=="Insert")) elseif(isset( $Action) && $Action=="New") elseif(isset( $Action) && $Action=="Edit") $Language
Definition: admin/articleedit.php:499
$readGroupsID
$readGroupsID
Definition: admin/articleedit.php:582
$ShowModuleLinker
$ShowModuleLinker
Definition: admin/articleedit.php:500
$article
$article
Definition: articlelog.php:45
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\addArticle
static addArticle( $value, $categoryid=false)
Definition: ezarticlecategory.php:1079
eZArticleCategory\isOwner
isOwner( $user, $categoryID)
Definition: ezarticlecategory.php:825
eZArticleCategory\removeArticle
static removeArticle( $value, $categoryid=false)
Definition: ezarticlecategory.php:1052
eZArticleGenerator
Definition: ezarticlegenerator.php:40
eZArticleTool\notificationMessage
static notificationMessage(&$article)
Definition: ezarticletool.php:136
eZArticleTool\deleteCache
static deleteCache( $ArticleID, $CategoryID, $CategoryArray)
Definition: ezarticletool.php:52
eZArticle
Definition: ezarticle.php:82
eZAuthor
Definition: ezauthor.php:40
eZDateTime
Definition: ezdatetime.php:55
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZObjectPermission\getGroups
static getGroups( $objectID, $moduleTable, $permission, $GroupReturn=true)
Definition: ezobjectpermission.php:365
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZObjectPermission\removePermissions
static removePermissions( $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:320
eZTemplate
Definition: eztemplate.php:107
eZTopic
Definition: eztopic.php:41
eZURLTranslator
Definition: ezurltranslator.php:38
eZUserGroup
Definition: ezusergroup.php:66
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZXML\domTree
static domTree( $xmlDoc, $params=array())
Definition: ezxml.php:60
$Action
$Action
Definition: companysearch.php:80
$ArticleID
$ArticleID
Definition: export.php:48
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$index
$index
Definition: ezforum/user/messageedit.php:36
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$Preview
$Preview
Definition: ezmessage/user/messageedit.php:121
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
$categoryID
else $categoryID
Definition: productview.php:66
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.