Exemplo n.º 1
0
/**
 * Copyright (C) 2008-2013 Ulteo SAS
 * http://www.ulteo.com
 * Author Julien LANGLOIS <*****@*****.**> 2008-2013
 * Author Laurent CLOUET <*****@*****.**> 2008-2011
 * Author Jeremy DESVAGES <*****@*****.**> 2008-2011
 * Author Vincent ROULLIER <*****@*****.**> 2013
 * Author David LECHEVALIER <*****@*****.**> 2012
 * Author David PHAM-VAN <*****@*****.**> 2013
 *
 * 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 Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
function init_db($prefs_)
{
    // prefs must be valid
    Logger::debug('main', 'init_db');
    $modules_enable = $prefs_->get('general', 'module_enable');
    foreach ($modules_enable as $module_name) {
        if (!is_null($prefs_->get($module_name, 'enable'))) {
            $enable = $prefs_->get($module_name, 'enable');
            if (is_string($enable)) {
                $mod_name = $module_name . '_' . $enable;
                $ret_eval = call_user_func(array($mod_name, 'init'), $prefs_);
                if ($ret_eval !== true) {
                    Logger::error('main', 'init_db init module \'' . $mod_name . '\' failed');
                    return false;
                }
            } elseif (is_array($enable)) {
                foreach ($enable as $sub_module) {
                    $mod_name = $module_name . '_' . $sub_module;
                    $ret_eval = call_user_func(array($mod_name, 'init'), $prefs_);
                    if ($ret_eval !== true) {
                        Logger::error('main', 'init_db init module \'' . $mod_name . '\' failed');
                        return false;
                    }
                }
            }
        }
    }
    Logger::debug('main', 'init_db modules inited');
    // Init of Abstract
    Abstract_Server::init($prefs_);
    Abstract_ServersGroup::init($prefs_);
    Abstract_Session::init($prefs_);
    Abstract_Token::init($prefs_);
    Abstract_News::init($prefs_);
    Abstract_Script::init($prefs_);
    Abstract_Liaison::init($prefs_);
    if (class_exists("PremiumManager")) {
        PremiumManager::initdb($prefs_);
    }
    Abstract_Task::init($prefs_);
    Abstract_ReportServer::init($prefs_);
    Abstract_ReportSession::init($prefs_);
    Abstract_User_Preferences::init($prefs_);
    Abstract_UserGroup_Preferences::init($prefs_);
    Abstract_UserGroup_Rule::init($prefs_);
    Abstract_VDI::init($prefs_);
    Abstract_Network_Folder::init($prefs_);
    Abstract_AdminAction::init($prefs_);
    return true;
}
Exemplo n.º 2
0
 public static function save($news_)
 {
     Logger::debug('main', 'Starting Abstract_News::save for \'' . $news_->id . '\'');
     $SQL = SQL::getInstance();
     $id = $news_->id;
     if (!Abstract_News::load($id)) {
         Logger::debug('main', "Abstract_News::save({$news_}) unable to load news, we must create it");
         $id = Abstract_News::create($news_);
         if (!$id) {
             Logger::error('main', "Abstract_News::save({$news_}) Abstract_News::create failed");
             return false;
         }
     }
     $SQL->DoQuery('UPDATE @1 SET @2=%3,@4=%5,@6=%7 WHERE @8 = %9 LIMIT 1', $SQL->prefix . 'news', 'title', $news_->title, 'content', $news_->content, 'timestamp', $news_->timestamp, 'id', $id);
     return true;
 }
Exemplo n.º 3
0
if ($_REQUEST['name'] == 'News') {
    if ($_REQUEST['action'] == 'add' && isset($_REQUEST['news_title']) && isset($_REQUEST['news_content'])) {
        $news = new News('');
        $news->title = $_REQUEST['news_title'];
        if ($news->title == '') {
            $news->title = '(' . _('Untitled') . ')';
        }
        $news->content = $_REQUEST['news_content'];
        $news->timestamp = time();
        $ret = Abstract_News::save($news);
        if ($ret === true) {
            popup_info(_('News successfully added'));
        }
        redirect();
    } elseif ($_REQUEST['action'] == 'del' && isset($_REQUEST['id'])) {
        $buf = Abstract_News::delete($_REQUEST['id']);
        if (!$buf) {
            popup_error(_('Unable to delete this news'));
        } else {
            popup_info(_('News successfully deleted'));
        }
        redirect();
    }
}
if ($_REQUEST['name'] == 'password') {
    if ($_REQUEST['action'] == 'change') {
        if (isset($_REQUEST['password_current']) && isset($_REQUEST['password']) && isset($_REQUEST['password_confirm'])) {
            if ($_REQUEST['password'] == '') {
                popup_error(_('Password is empty'));
            } else {
                if ($_REQUEST['password'] != $_REQUEST['password_confirm']) {
Exemplo n.º 4
0
function show_manage($news_id_)
{
    $news = Abstract_News::load($news_id_);
    if (!is_object($news)) {
        redirect('news.php');
    }
    $can_manage_news = isAuthorized('manageNews');
    page_header();
    echo '<div id="news_div">';
    echo '<h1>' . $news->title . '</h1>';
    echo '<div>';
    echo '<h2>' . _('Modify') . '</h2>';
    echo '<table border="0" cellspacing="1" cellpadding="3">';
    if ($can_manage_news) {
        echo '<form action="news.php" method="post">';
        echo '<input type="hidden" name="action" value="rename" />';
        echo '<input type="hidden" name="id" value="' . $news->id . '" />';
        echo '<tr><td><strong>Title:</strong></td><td><input type="text" name="news_title" value="' . $news->title . '" /></td></tr>';
        echo '<tr><td><strong>Content:</strong></td><td><textarea name="news_content" cols="40" rows="4">' . $news->content . '</textarea></td></tr>';
        echo '<tr><td colspan="2"><input type="submit" value="' . _('Modify') . '" /></td></tr>';
        echo '</form>';
    }
    echo '</table>';
    echo '</div>';
    echo '</div>';
    page_footer();
}
Exemplo n.º 5
0
 * 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 Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php';
$news = Abstract_News::load_all();
$dom = new DomDocument('1.0', 'utf-8');
$news_node = $dom->createElement('news');
foreach ($news as $new) {
    $new_node = $dom->createElement('new');
    $new_node->setAttribute('id', $new->getAttribute('id'));
    $new_node->setAttribute('title', $new->getAttribute('title'));
    $new_node->setAttribute('timestamp', (int) $new->getAttribute('timestamp'));
    $new_textnode = $dom->createTextNode($new->getAttribute('content'));
    $new_node->appendChild($new_textnode);
    $news_node->appendChild($new_node);
}
$dom->appendChild($news_node);
header('Content-Type: text/xml; charset=utf-8');
echo $dom->saveXML();
die;
Exemplo n.º 6
0
 public function news_remove($id_)
 {
     $this->check_authorized('manageNews');
     $buf = Abstract_News::delete($id_);
     if (!$buf) {
         return false;
     }
     $this->log_action('news_remove', array('id' => $id_));
     return true;
 }