phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] news_admin/inc class.sonews.inc.php, 1.6 class.soexpo


From: skwashd
Subject: [Phpgroupware-cvs] news_admin/inc class.sonews.inc.php, 1.6 class.soexport.inc.php, 1.3 class.uiacl.inc.php, 1.3 class.uiexport.inc.php, 1.3 hook_admin.inc.php, 1.11 class.uinews.inc.php, 1.29 class.soacl.inc.php, 1.3 class.bonews.inc.php, 1.6 class.boacl.inc.php, 1.3 class.boexport.inc.php, 1.3 hook_home.inc.php, 1.5
Date: Thu, 4 Aug 2005 05:54:00 +0200

Update of news_admin/inc

Modified Files:
     Branch: MAIN
            class.sonews.inc.php lines: +0 -0
            class.soexport.inc.php lines: +0 -0
            class.uiacl.inc.php lines: +0 -0
            class.uiexport.inc.php lines: +0 -0
            hook_admin.inc.php lines: +24 -5
            class.uinews.inc.php lines: +327 -149
            class.soacl.inc.php lines: +0 -0
            class.bonews.inc.php lines: +0 -0
            class.boacl.inc.php lines: +8 -6
            class.boexport.inc.php lines: +0 -0
            hook_home.inc.php lines: +0 -0

Log Message:
new newsletter builder, updated FCK and a few other things

====================================================

====================================================

====================================================

====================================================

====================================================
Index: news_admin/inc/hook_admin.inc.php
diff -u news_admin/inc/hook_admin.inc.php:1.10 
news_admin/inc/hook_admin.inc.php:1.11
--- news_admin/inc/hook_admin.inc.php:1.10      Wed May 25 01:19:51 2005
+++ news_admin/inc/hook_admin.inc.php   Thu Aug  4 03:54:31 2005
@@ -2,7 +2,7 @@
   /**************************************************************************\
   * phpGroupWare                                                             *
   * http://www.phpgroupware.org                                              *
-  * Written by Joseph Engo <address@hidden>                          *
+  * Written by Joseph Engo, Michael Totschnig  and Dave Hall                 *
   * --------------------------------------------                             *
   *  This program is free software; you can redistribute it and/or modify it *
   *  under the terms of the GNU General Public License as published by the   *
@@ -11,11 +11,30 @@
   \**************************************************************************/
   /* $Id$ */
        {
-               $file = Array
+               $file = array
                (
-                       'Global Categories'     => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname='
 . $appname),
-                       'Configure Access Permissions' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uiacl.acllist'),
-                       'Configure RSS exports' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uiexport.exportlist'),
+                               'Site Configuration'    => 
$GLOBALS['phpgw']->link('/index.php',
+                                                               array
+                                                               (
+                                                                       
'menuaction'    => 'admin.uiconfig.index',
+                                                                       
'appname'       => 'news_admin'
+                                                               ) ),
+                               'Global Categories'     => 
$GLOBALS['phpgw']->link('/index.php',
+                                                               array
+                                                               (
+                                                                       
'menuaction'    => 'admin.uicategories.index',
+                                                                       
'appname'       => 'news_admin'
+                                                               ) ),
+                               'Configure Access Permissions' => 
$GLOBALS['phpgw']->link('/index.php',
+                                                               array
+                                                               (
+                                                                       
'menuaction'    => 'news_admin.uiacl.acllist'
+                                                               ) ),
+                               'Configure RSS exports' => 
$GLOBALS['phpgw']->link('/index.php',
+                                                               array
+                                                               (
+                                                                       
'menuaction'    => 'news_admin.uiexport.exportlist'
+                                                               ) )
                );
                display_section($appname,$appname,$file);
        }

====================================================
Index: news_admin/inc/class.uinews.inc.php
diff -u news_admin/inc/class.uinews.inc.php:1.28 
news_admin/inc/class.uinews.inc.php:1.29
--- news_admin/inc/class.uinews.inc.php:1.28    Wed May 25 01:19:51 2005
+++ news_admin/inc/class.uinews.inc.php Thu Aug  4 03:54:31 2005
@@ -28,16 +28,22 @@
                var $news_data;
                var $news_id;
                var $sbox;
-               var $public_functions = array(
-                       'write_news'    => True,
+               var $public_functions = array
+                                       (
                        'add'           => True,
                        'edit'          => True,
                        'delete'        => True,
                        'delete_item'   => True,
+                                               'newsletter'    => True,
+                                               'newsletter_send'=> True,
                        'read_news'      => True,
-                       'show_news_home' => True
+                                               'show_news_home'=> True,
+                                               'write_news'    => True
                );

+               /**
+               * @constructor
+               */
                function uinews()
                {
                        $this->nextmatchs = createobject('phpgwapi.nextmatchs');
@@ -51,36 +57,6 @@
                        $this->cat_id = $this->bo->cat_id;
                }

-               //with $default, we are called from the news form
-               function selectlist($type, $default=false)
-               {
-                       $link_data['menuaction'] = ($type == 'read') ? 
'news_admin.uinews.read_news' : 'news_admin.uinews.write_news';
-                       $link_data['start'] = 0;
-                       $right = ($type == 'read') ? PHPGW_ACL_READ : 
PHPGW_ACL_ADD;
-                       $selectlist = ($default === false) ? ('<option>' . 
lang($type . ' news') . '</option>') : '';
-                       $cats = is_array($this->bo->cats) ? $this->bo->cats : 
array();
-                       foreach($cats as $cat)
-                       {
-                               
if($this->bo->acl->is_permitted($cat['id'],$right))
-                               {
-                                       $cat_id = (int) $cat['id'];
-                                       $link_data['cat_id'] = $cat_id;
-                                       $selectlist .= '<option value="';
-                                       $selectlist .= $default !== False ? 
$cat_id : $GLOBALS['phpgw']->link('/index.php',$link_data);
-                                       $selectlist .= '"';
-                                       $selectlist .= ($default === $cat_id) ? 
' selected="selected"' : '';
-                                       $selectlist .= '>' . $cat['name'] . 
'</option>' . "\n";
-                               }
-                       }
-                       if (!$default)
-                       {
-                               $link_data['cat_id'] = 'all';
-                               $selectlist .= '<option 
style="font-weight:bold" value="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data)
-                                       . '">' . lang('All news') . '</option>' 
 . "\n";
-                       }
-                       return $selectlist;
-               }
-
                /**
                * Display a list of news items for the user to read
                */
@@ -99,12 +75,13 @@
                        $this->template->set_block('news', 'cat_form', 
'cat_frm');
                        $this->template->set_block('news', 'less_li', 'less');
                        $this->template->set_block('news', 'maintain_li', 
'maintain');
+                       $this->template->set_block('news', 'newsletter_li', 
'newsletter');
                        $this->template->set_block('news', 'more_li', 'more');
                        $this->template->set_block('news', 'news_item', 
'news_items');
                        $this->template->set_block('news', 'summary_item', 
'summary_items');
                        $this->template->set_block('news','news_summary', 
'news_sum');

-                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"/><style 
type="text/css">';
+                       $GLOBALS['phpgw_info']['flags']['css'] .= 
"-->\n</style>\n<link rel=\"StyleSheet\" 
href=\"{$GLOBALS['phpgw_info']['server']['webserver_url']}/news_admin/css/base.css\"/>\n<style
 type=\"text/css\"><!--\n";

                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();
@@ -168,6 +145,26 @@
                                $this->template->set_var('maintain', '&nbsp;');
                        }

+                       if ( count( $this->bo->acl->get_permissions() ) > 1 )
+                       {
+                               $this->template->set_var(
+                                                       array
+                                                               (
+                                                                       
'href_newsletter'       => $GLOBALS['phpgw']->link('/index.php',
+                                                                               
                        array('menuaction' => 'news_admin.uinews.newsletter')
+                                                                               
                        ),
+                                                                       
'lang_newsletter'       => lang('create newsletter')
+                                                               )
+                                                       );
+
+                               $this->template->parse('newsletter', 
'newsletter_li');
+                       }
+                       else
+                       {
+                               $this->template->set_var('newsletter', 
'&nbsp;');
+
+                       }
+
                        if ( !$this->bo->total )
                        {
                                $this->template->set_var('content', lang('No 
entries found') );
@@ -242,7 +239,10 @@
                        $this->template->pfp('out','news');
                }

-               //this is currently broken
+               /**
+               * Display news on the "home screen" called by hook_home
+               * @internal this is currently broken
+               */
                function show_news_home()
                {
                        $title = '<font color="#FFFFFF">'.lang('News 
Admin').'</font>';
@@ -259,7 +259,7 @@
                        $app_id = 
$GLOBALS['phpgw']->applications->name2id('news_admin');
                        $GLOBALS['portal_order'][] = $app_id;

-                       $var = Array(
+                       $btns = Array(
                                'up'       => Array('url' => '/set_box.php', 
'app' => $app_id),
                                'down'     => Array('url' => '/set_box.php', 
'app' => $app_id),
                                'close'    => Array('url' => '/set_box.php', 
'app' => $app_id),
@@ -267,12 +267,13 @@
                                'edit'     => Array('url' => '/set_box.php', 
'app' => $app_id)
                        );

-                       while(list($key,$value) = each($var))
+                       foreach($btns as $key => $value)
                        {
                                $portalbox->set_controls($key,$value);
                        }
+                       unset($btns);

-                       $newslist = 
$this->bo->get_newslist($this->cat_id,0,'','',5,True);
+                       $newslist = $this->bo->get_newslist($this->cat_id, 0, 
'', '', $GLOBALS['phpgw_info']['common']['maxmatchs'], True);

                        $image_path = 
$GLOBALS['phpgw']->common->get_image_path('news_admin');

@@ -303,68 +304,21 @@
                        $this->template->pfp('out', 'phpgw_body');
                }

-               //the following function is unmaintained
+               /**
+               * Show news on the "website", replaced by sitemgr news module/s
+               * @internal the following function is unmaintained
+               *
+               * @param string $section the "section" of the page where news 
will be displayed
+               * @returns string Error message
+               */
                function show_news_website($section='mid')
                {
-                       $cat_id = $_GET['cat_id'];
-                       $start = $_GET['start'];
-                       $oldnews = $_GET['oldnews'];
-                       $news_id = $_GET['news_id'];
-
-                       if (! $cat_id)
-                       {
-                               $cat_id = 0;
-                       }
-
-                       $this->template->set_file(array(
-                               '_news' => 'news_' . $section . '.tpl'
-                       ));
-                       $this->template->set_block('_news','news_form');
-                       $this->template->set_block('_news','row');
-                       $this->template->set_block('_news','category');
-
-
-                       if($news_id)
-                       {
-                               $news = array($news_id => 
$this->bo->get_news($news_id));
-                       }
-                       else
-                       {
-                               $news = 
$this->bo->get_NewsList($cat_id,$oldnews,$start,$total);
-                       }
-
-                       $var = Array();
-
-                       
$this->template->set_var('icon',$GLOBALS['phpgw']->common->image('news_admin','news-corner.gif'));
-
-                       foreach($news as $newsitem)
-                       {
-                               $var = Array(
-                                       'subject'=> $newsitem['subject'],
-                                       'submitedby' => 'Submitted by ' . 
$GLOBALS['phpgw']->accounts->id2name($newsitem['submittedby']) . ' on ' . 
$GLOBALS['phpgw']->common->show_date($newsitem['date']),
-                                       'content'    => 
nl2br($newsitem['content'])
-                               );
-
-                               $this->template->set_var($var);
-                               $this->template->parse('rows','row',True);
-                       }
-
-                       $out = $this->template->fp('out','news_form');
-
-                       if ($this->bo->total > 5 && ! $oldnews)
-                       {
-                               $link_values = array(
-                                       'menuaction'    => 
'news_admin.uinews.show_news',
-                                       'oldnews'       => 'True',
-                                       'cat_id'        => $cat_id,
-                                       'category_list' => 'True'
-                               );
-
-                               $out .= '<center><a href="' . 
$GLOBALS['phpgw']->link('/index.php',$link_values) . '">View news 
archives</a></center>';
-                       }
-                       return $out;
+                       return "uinews::show_news_website({$section}) has been 
removed, please use sitemgr module";
                }

+               /**
+               * Add a new news item
+               */
                function add()
                {
                        if($_POST['cancel'])
@@ -391,7 +345,7 @@
                                        $this->message = lang('Message has been 
added');
                                        //after having added, we must switch to 
edit mode instead of stay in add
                                        $this->news_data = 
$this->bo->get_news($this->news_id,True);
-                                       $this->modify('edit');
+                                       $this->_modify('edit');
                                        return;
                                }
                                else
@@ -403,9 +357,12 @@
                        {
                                $this->news_data['category'] = $this->cat_id;
                        }
-                       $this->modify('add');
+                       $this->_modify('add');
                }

+               /**
+               * Confirm deletition of a news item
+               */
                function delete()
                {
                        $news_id = $_POST['news_id'] ? $_POST['news_id'] : 
$_GET['news_id'];
@@ -425,6 +382,9 @@
                        $this->template->pfp('_out','form');
                }

+               /**
+               * Delete a news item
+               */
                function delete_item()
                {
                        $item = intval(get_var('news_id'));
@@ -440,6 +400,9 @@
                        $this->write_news($msg);
                }

+               /**
+               * Edit an existing news item
+               */
                function edit()
                {
                        $jscal = createObject('phpgwapi.jscalendar', False);
@@ -484,84 +447,180 @@
                        }

                        $this->news_data = 
$this->bo->get_news($this->news_id,True);
-                       $this->modify();
+                       $this->_modify();
                }

-               function modify($type = 'edit')
+               /**
+               * Create an email newsletter from news items
+               */
+               function newsletter()
                {
+                       $msg = '';
+                       $content = '';
+                       $config = createObject('phpgwapi.config');
+                       $config->read_repository();
+                       //echo '<pre>' . print_r($config->config_data, true) . 
'</pre>';
+                       if ( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' )
+                       {
+                               if ( isset($_POST['send']) && $_POST['send'] )
+                               {
+                                       $content = 
stripslashes(str_replace(array('<script','</script'), 
array('&lt;script','&lt;/script'), preg_replace("' on(.*?)=\"(.*?)\"'i", '', 
get_var('nl_content', array('POST') ) ) ) );
+                                       $html2text = 
createObject('news_admin.html2text', $content);
+                                       $content_txt = $html2text->get_text();
+                                       unset($html2text);
+
+                                       $smtp = 
createObject('news_admin.mailer_smtp');
+                                       $smpt->CharSet = lang('charset');
+                                       $smtp->From = $smtp->Sender = 
$config->config_data['newsletter_from_email'];
+                                       $smtp->FromName = 
$config->config_data['newsletter_from_name'];
+                                       
$smtp->AddAddress($config->config_data['newsletter_to']);
+                                       $smtp->Subject = get_var('subject', 
array('POST'));
+
+                                       if ( isset($_POST['bcc_recipients']) && 
is_array($_POST['bcc_recipients']) )
+                                       {
+                                               $bcc_recips = 
get_var('bcc_recipients', array('POST') );
+                                               foreach ( $bcc_reips as $bcc )
+                                               {
+                                                       $smtp->AddBCC($bcc);
+                                               }
+                                       }
+
+                                       if ( 
$config->config_data['force_plain'] )
+                                       {
+                                               unset($content);
+                                               $smtp->IsHTML(false);
+                                               $smtp->Body = $content_txt;
+                                       }
+                                       else
+               {
+                                               $smtp->IsHTML(true);
+                                               $smtp->Body = $content;
+                                               $smtp->AltBody = $content_txt;
+                                       }
+                                       unset($content_txt);
+
+                                       //FIXME: Handle this better
+                                       if ( $smtp->Send() )
+                                       {
+                                               $msg = lang('newsletter sent');
+                                               $content = '';
+                                       }
+                                       else
+                                       {
+                                               $msg = lang('sending newsletter 
failed: %1', $smtp->ErrorInfo);
+                                       }
+                               }
+                       }
+
+                       if ( !$content )
+                       {
+                               $content = str_replace(
+                                               array('<script','</script'),
+                                               
array('&lt;script','&lt;/script'),
+                                               preg_replace("' 
on(.*?)=\"(.*?)\"'i",
+                                                       '',
+                                                       
$config->config_data['newsletter_header_html']
+                                                               . "\n"
+                                                               . 
$config->config_data['newsletter_footer_html']
+                                               )
+                                       );
+                       }
+
                        if ( !is_object($GLOBALS['phpgw']->js) )
                        {
                                $GLOBALS['phpgw']->js = 
CreateObject('phpgwapi.javascript');
                        }

-                       $GLOBALS['phpgw']->js->validate_file('base', 'toggle', 
'news_admin');
-                       $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckconfig', 'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('base', 'tabs', 
'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('base', 
'news_builder', 'news_admin');
                        $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckeditor', 'news_admin');
                        $GLOBALS['phpgw_info']['flags']['java_script'] = '
                                <script type="text/javascript">
                                <!--
+                                       //Global scope
+                                       var oTabs;
+                                       var strLinkURL = \'' . 
$config->config_data['more_link_url'] . '\';
                                window.onload = function()
                                {
-                                       var oFCKeditor = new 
FCKeditor(\'news[content]\');
-                                       oFCKeditor.ReplaceTextarea();
-                                       toggle();
+                                               var oFCKEditor = new 
FCKeditor(\'nl_content\');
+                                               oFCKEditor.BasePath = "' . 
$GLOBALS['phpgw_info']['server']['webserver_url'] . '/news_admin/js/fckeditor/";
+                                               oFCKEditor.SpellChecker = \'' . 
(extension_loaded('pspell') ? 'SpellerPages' : 'ieSpell') . '\'
+                                               oFCKEditor.ReplaceTextarea();
+                                               setTimeout("nlbLoaded()", 
2000); //stops FCK FCKing up
                                }
-                               //-->
-                               </script>';
-
-                       $jscal = createObject('phpgwapi.jscalendar');

-                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"/><style 
type="text/css">';
+                                       oLang = {
+                                                       read_more: "' . 
lang('read more') . ' >>"
+                                               }
+                               //-->
+                               </script>
+                               <noscript>
+                                       <p>' . lang('newsletter builder 
requires javascript to be enabled') . '!</p>
+                               </noscript>
+                       ';
+                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"><style 
type="text/css">';

                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();

-                       $this->template->set_file( array('form' => 
'admin_form.tpl') );
-
-                       if ( is_array($this->message) )
-                       {
-                               
$this->template->set_var('errors',$GLOBALS['phpgw']->common->error_list($this->message));
-                       }
-                       elseif ( $this->message )
-                       {
-                               
$this->template->set_var('errors',$this->message);
-                       }
-
-                       $this->template->set_var('lang_header',lang($type . ' 
news item'));
-                       
$this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php',
-                               array('menuaction'      => 
'news_admin.uinews.'.$type,
-                                               'news_id'       => 
$this->news_id
-                                       )
-                               )
-                       );
-
-                       //echo '<br />UI:<br /><pre>'; 
print_r($this->news_data); echo '</pre>';
-
-                       $this->template->set_var( 
$this->_get_option_vals($this->news_data) );
+                       $this->template->set_file(array('newsletter' => 
'newsletter_creator.tpl'));
+                       $this->template->set_block('newsletter', 'article', 
'articles');
                        $this->template->set_var(
                                                array
                                                        (
-                                                               'form_button'   
=> lang('save'),
-                                                               'value_id'      
=> $this->news_id,
-                                                               'done_button'   
=> lang('done'),
-                                                               'label_subject' 
=> lang('subject'),
-                                                               'value_subject' 
=> htmlentities($this->news_data['subject']),
-                                                               'label_teaser'  
=> lang('summary'),
-                                                               'value_teaser'  
=> htmlentities($this->news_data['teaser']),
-                                                               'value_content' 
=> htmlentities($this->news_data['content']),
-                                                               
'label_category'=> lang('category'),
-                                                               
'value_category'=> $this->selectlist('write', 
intval($this->news_data['category'])),
-                                                               'label_visible' 
=> lang('visible'),
-                                                               'value_begin'   
=> $jscal->input('news[begin]', $this->news_data['begin']),
-                                                               'select_from'   
=> $options['from'],
-                                                               'select_until'  
=> $options['until'],
-                                                               'value_end'     
=> $jscal->input('news[end]', $this->news_data['end']),
+                                                               'form_action'   
        => $GLOBALS['phpgw']->link('/index.php',
+                                                                               
                array
+                                                                               
                (
+                                                                               
                        'menuaction'    => 'news_admin.uinews.newsletter'
+                                                                               
                )),
+                                                               'href_cancel'   
        => $GLOBALS['phpgw']->link('/news_admin/index.php'),
+                                                               'href_help'     
        => $GLOBALS['phpgw']->link('/index.php',
+                                                                               
                array
+                                                                               
                (
+                                                                               
                        'menuaction'    => 'news_admin.uinews.help'
+                                                                               
                )),
+                                                               'img_cancel'    
        => $GLOBALS['phpgw']->common->find_image('news_admin', 'cancel'),
+                                                               'img_help'      
        => $GLOBALS['phpgw']->common->find_image('news_admin', 'help'),
+                                                               'img_send'      
        => $GLOBALS['phpgw']->common->find_image('news_admin', 'send'),
+                                                               'lang_add'      
        => lang('add'),
+                                                               
'lang_all_changes_will_be_lost' => lang('all changes will be lost'),
+                                                               
'lang_bcc_recipients'   => lang('bcc recipients'),
+                                                               'lang_articles' 
        => lang('articles'),
+                                                               'lang_author'   
        => lang('author'),
+                                                               'lang_cancel'   
        => lang('cancel'),
+                                                               'lang_help'     
        => lang('help'),
+                                                               'lang_message'  
        => lang('message'),
+                                                               'lang_preview'  
        => lang('preview'),
+                                                               
'lang_recipients'       => lang('recipients'),
+                                                               'lang_remove'   
        => lang('remove'),
+                                                               'lang_send'     
        => lang('send'),
+                                                               'lang_subject'  
        => lang('subject'),
+                                                               'lang_title'    
        => lang('title'),
+                                                               'messages'      
        => $msgs,
+                                                               'nl_content'    
        => htmlentities($content),
                                                        )
                                                );

-                       $this->template->pfp('out','form');
+                       $news = $this->bo->get_all_public_news(-1);
+
+                       $i = 0;
+                       foreach($news as $item)
+                       {
+                               //echo '<pre>' . print_r($item, True) . 
'</pre>';
+                               $item['css_row'] = 'row_' . ( $i%2 ? 'on' : 
'off');
+                               $item['author'] = 
$GLOBALS['phpgw']->accounts->id2name($item['submittedby']);
+                               $this->template->set_var($item);
+                               $this->template->parse('articles', 'article', 
True);
+                               ++$i;
+                       }
+                       $this->template->pfp('out', 'newsletter');
                }

+               /**
+               * Write a news item
+               *
+               * @param string $message action feedback message to user
+               */
                function write_news($message = '')
                {
                        $this->template->set_file(array('main' => 'write.tpl'));
@@ -574,7 +633,7 @@
                        $this->template->set_block('main','category');
                        $var['lang_read'] = lang('Read');
                        $var['lang_write'] = lang('Write');
-                       $var['readable'] = $this->selectlist('read');
+                       $var['readable'] = $this->_selectlist('read');
                        $var['cat_name'] = $this->cat_id ? 
$this->bo->catbo->id2name($this->cat_id) : lang('Global news');

                        $this->template->set_var($var);
@@ -640,6 +699,9 @@

                /**
                * Get the values needed for build the date range fields in edit 
mode
+               *
+               * @param array $news news item record
+               * @returns array values as jscal friendly array
                */
                function _get_option_vals(&$news)
                {
@@ -723,6 +785,122 @@

                        }
                        return $options;
+               }
+
+               /**
+               * Render story editor
+               *
+               * @access private
+               * @param string $type edit or create
+               */
+               function _modify($type = 'edit')
+               {
+                       if ( !is_object($GLOBALS['phpgw']->js) )
+                       {
+                               $GLOBALS['phpgw']->js = 
CreateObject('phpgwapi.javascript');
+                       }
+
+                       $GLOBALS['phpgw']->js->validate_file('base', 'toggle', 
'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckconfig', 'news_admin');
+                       $GLOBALS['phpgw']->js->validate_file('fckeditor', 
'fckeditor', 'news_admin');
+                       $GLOBALS['phpgw_info']['flags']['java_script'] = '
+                               <script type="text/javascript">
+                               <!--
+                                       window.onload = function()
+                                       {
+                                               var oFCKeditor = new 
FCKeditor(\'news[content]\');
+                                               oFCKeditor.BasePath = "' . 
$GLOBALS['phpgw_info']['server']['webserver_url'] . '/news_admin/js/fckeditor/";
+                                               oFCKeditor.ReplaceTextarea();
+                                               toggle();
+                                       }
+                               //-->
+                               </script>';
+
+                       $jscal = createObject('phpgwapi.jscalendar');
+
+                       $GLOBALS['phpgw_info']['flags']['css'] .= 
'</style><link rel="StyleSheet" href="news_admin/css/base.css"/><style 
type="text/css">';
+
+                       $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
+
+                       $this->template->set_file( array('form' => 
'admin_form.tpl') );
+
+                       if ( is_array($this->message) )
+                       {
+                               
$this->template->set_var('errors',$GLOBALS['phpgw']->common->error_list($this->message));
+                       }
+                       elseif ( $this->message )
+                       {
+                               
$this->template->set_var('errors',$this->message);
+                       }
+
+                       $this->template->set_var('lang_header',lang($type . ' 
news item'));
+                       
$this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php',
+                                               array
+                                               (
+                                                       'menuaction'    => 
'news_admin.uinews.'.$type,
+                                                       'news_id'       => 
$this->news_id
+                                               )
+                                       )
+                               );
+
+                       //echo '<br />UI:<br /><pre>'; 
print_r($this->news_data); echo '</pre>';
+
+                       $this->template->set_var( 
$this->_get_option_vals($this->news_data) );
+                       $this->template->set_var(
+                                               array
+                                                       (
+                                                               'img_cancel'    
=> $GLOBALS['phpgw']->common->find_image('news_admin', 'cancel'),
+                                                               'img_save'      
=> $GLOBALS['phpgw']->common->find_image('news_admin', 'save'),
+                                                               'lang_save'     
=> lang('save'),
+                                                               'value_id'      
=> $this->news_id,
+                                                               'lang_cancel'   
=> lang('cancel'),
+                                                               'label_subject' 
=> lang('subject'),
+                                                               'value_subject' 
=> htmlentities($this->news_data['subject']),
+                                                               'label_teaser'  
=> lang('summary'),
+                                                               'value_teaser'  
=> htmlentities($this->news_data['teaser']),
+                                                               'value_content' 
=> htmlentities($this->news_data['content']),
+                                                               
'label_category'=> lang('category'),
+                                                               
'value_category'=> $this->_selectlist('write', 
intval($this->news_data['category'])),
+                                                               'label_visible' 
=> lang('visible'),
+                                                               'value_begin'   
=> $jscal->input('news[begin]', $this->news_data['begin']),
+                                                               'select_from'   
=> $options['from'],
+                                                               'select_until'  
=> $options['until'],
+                                                               'value_end'     
=> $jscal->input('news[end]', $this->news_data['end']),
+                                                       )
+                                               );
+
+                       $this->template->pfp('out','form');
+               }
+
+               //with $default, we are called from the news form
+               function _selectlist($type, $default=false)
+               {
+                       $link_data['menuaction'] = ($type == 'read') ? 
'news_admin.uinews.read_news' : 'news_admin.uinews.write_news';
+                       $link_data['start'] = 0;
+                       $right = ($type == 'read') ? PHPGW_ACL_READ : 
PHPGW_ACL_ADD;
+                       $selectlist = ($default === false) ? ('<option>' . 
lang($type . ' news') . '</option>') : '';
+                       $cats = is_array($this->bo->cats) ? $this->bo->cats : 
array();
+                       foreach($cats as $cat)
+                       {
+                               
if($this->bo->acl->is_permitted($cat['id'],$right))
+                               {
+                                       $cat_id = (int) $cat['id'];
+                                       $link_data['cat_id'] = $cat_id;
+                                       $selectlist .= '<option value="';
+                                       $selectlist .= $default !== False ? 
$cat_id : $GLOBALS['phpgw']->link('/index.php',$link_data);
+                                       $selectlist .= '"';
+                                       $selectlist .= ($default === $cat_id) ? 
' selected="selected"' : '';
+                                       $selectlist .= '>' . $cat['name'] . 
'</option>' . "\n";
+                               }
+                       }
+                       if (!$default)
+                       {
+                               $link_data['cat_id'] = 'all';
+                               $selectlist .= '<option 
style="font-weight:bold" value="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data)
+                                       . '">' . lang('All news') . '</option>' 
 . "\n";
+                       }
+                       return $selectlist;
                }
        }
 ?>

====================================================

====================================================

====================================================
Index: news_admin/inc/class.boacl.inc.php
diff -u news_admin/inc/class.boacl.inc.php:1.2 
news_admin/inc/class.boacl.inc.php:1.3
--- news_admin/inc/class.boacl.inc.php:1.2      Wed May 25 01:19:51 2005
+++ news_admin/inc/class.boacl.inc.php  Thu Aug  4 03:54:31 2005
@@ -106,17 +106,19 @@
                        $writecat = $write ? $write : array();

                        $this->so->remove_location('L' . $cat_id);
-                       reset($this->accounts);
-                       while (list($null,$account) = each($this->accounts))
+                       foreach($this->accounts as $ign => $account)
                        {
                                $account_id = $account['account_id'];
                                //write implies read
-                               $rights = in_array($account_id,$writecat) ?
-                                       (PHPGW_ACL_READ | PHPGW_ACL_ADD) :
-                                       (in_array($account_id,$readcat) ? 
PHPGW_ACL_READ : False);
+                               $rights = in_array($account_id, $writecat)
+                                               ? (PHPGW_ACL_READ | 
PHPGW_ACL_ADD)
+                                               : 
(in_array($account_id,$readcat) ? PHPGW_ACL_READ : 0 );
                                if ($rights)
                                {
-                                       
$GLOBALS['phpgw']->acl->add_repository('news_admin','L'.$cat_id,$account_id,$rights);
+                                       
$GLOBALS['phpgw']->acl->add_repository('news_admin',
+                                                                               
'L'.$cat_id,
+                                                                               
$account_id,
+                                                                               
$rights );
                                }
                        }
                }

====================================================

====================================================






reply via email to

[Prev in Thread] Current Thread [Next in Thread]