/** * 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; }
public static function save($script_) { Logger::debug('main', 'Starting Abstract_Script::save for \'' . $script_->id . '\''); $SQL = SQL::getInstance(); $id = $script_->id; if (!Abstract_Script::load($id)) { Logger::debug('main', "Abstract_Script::save({$script_}) unable to load script, we must create it"); $id = Abstract_Script::create($script_); if (!$id) { Logger::error('main', "Abstract_Script::save({$script_}) Abstract_Script::create failed"); return false; } } if ($script_->name == '') { $script_->name = "Untitled " . $id; } $SQL->DoQuery('UPDATE #1 SET @2=%3,@4=%5,@6=%7,@8=%9 WHERE @10 = %11 LIMIT 1', self::$table, 'name', $script_->name, 'os', $script_->os, "type", $script_->type, 'data', $script_->data, 'id', $id); return true; }
public function scripts() { Logger::debug('main', 'USER::scripts()'); $scripts_tmp = Abstract_Script::load_all(); $my_scripts_id = array(); $my_scripts = array(); $publications = Abstract_Liaison::load('Scripts', NULL, NULL); foreach ($publications as $publication) { if (in_array($publication->element, $my_scripts_id)) { continue; } $my_scripts_id[] = $publication->group; } // from this group, which are these I am into $users_groups_mine_ids = $this->get_my_usersgroups_from_list($my_scripts_id); foreach ($publications as $publication) { if (!in_array($publication->group, $users_groups_mine_ids)) { continue; } foreach ($scripts_tmp as $script) { if ($script->getAttribute('id') == $publication->element) { array_push($my_scripts, $script); } } } return array_unique($my_scripts); }
public function getScripts() { Logger::debug('main', 'SERVER::getScripts'); $scripts = array(); $scripts_tmp = Abstract_Script::load_all(); foreach ($scripts_tmp as $script) { if (strtolower($script->getAttribute("os")) == strtolower($this->type) && $this->isOnline()) { $scripts[] = $script; } } return $scripts; }
public function scripts_groups_list($group_id_) { $this->check_authorized('viewScripts'); $liaisons = Abstract_Liaison::load('Scripts', NULL, $group_id_); $res = array(); if (count($liaisons) > 0) { foreach ($liaisons as $liaison) { $script = Abstract_Script::load($liaison->element); if (!is_object($script)) { continue; } $res[$script->id] = self::generate_script_array($script); } } return $res; }