[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * Copywrite (c) 2004 by RalfBecker@outdoor-training.de * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: default_records.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 $sitemgr_table_prefix = 'egw_sitemgr'; 16 $oProc->query("INSERT INTO {$GLOBALS['egw_setup']->cats_table} (cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,last_mod) VALUES (0,-1,'public','sitemgr','Default Website','This website has been added by setup',".time().")"); 17 $site_id = $oProc->m_odb->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); 18 $oProc->query("UPDATE {$GLOBALS['egw_setup']->cats_table} SET cat_main = $site_id WHERE cat_id = $site_id",__LINE__,__FILE__); 19 20 $oProc->query("SELECT config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name='webserver_url'"); 21 $oProc->next_record(); 22 $siteurl = $oProc->f('config_value') . '/sitemgr/sitemgr-site/'; // url always uses slashes, dont use SEP!!! 23 $sitedir = $GLOBALS['egw_setup']->db->db_addslashes(EGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'sitemgr-site'); 24 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_sites (site_id,site_name,site_url,site_dir,themesel,site_languages,home_page_id,anonymous_user,anonymous_passwd) VALUES ($site_id,'Default Website','$siteurl','$sitedir','idots','en,de',0,'anonymous','anonymous')"); 25 26 // give Admins group rights vor sitemgr and for the created default-site 27 $admingroup = $GLOBALS['egw_setup']->add_account('Admins','Admin','Group',False,False); 28 $GLOBALS['egw_setup']->add_acl('sitemgr','run',$admingroup); 29 $GLOBALS['egw_setup']->add_acl('sitemgr',"L$site_id",$admingroup); 30 // give Default group rights vor sitemgr-link 31 $defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); 32 $GLOBALS['egw_setup']->add_acl('sitemgr-link','run',$defaultgroup); 33 34 // Create anonymous user for sitemgr 35 $GLOBALS['egw_setup']->add_account('NoGroup','No','Rights',False,False); 36 $anonymous = $GLOBALS['egw_setup']->add_account('anonymous','SiteMgr','User','anonymous','NoGroup'); 37 // give the anonymous user only sitemgr-link-rights 38 $GLOBALS['egw_setup']->add_acl('sitemgr-link','run',$anonymous); 39 $GLOBALS['egw_setup']->add_acl('phpgwapi','anonymous',$anonymous); 40 41 // register all modules and allow them in the following contentareas 42 // note '__PAGE__' is used for contentareas with NO module specialy selected, eg. only 'center' in this example !!! 43 $areas = array( 44 'administration' => array('left','right'), 45 'amazon' => array('left','right'), 46 'calendar' => array('left','right'), 47 'currentsection' => array('left','right'), 48 'download' => array('__PAGE__'), 49 'filecontents' => array('left','right','header','footer','__PAGE__'), 50 'frame' => array('__PAGE__'), 51 'google' => array('left','right'), 52 'html' => array('left','right','header','footer','__PAGE__'), 53 'lang_block' => array('left','right'), 54 'login' => array('left','right'), 55 'navigation' => array('left','right','__PAGE__'), 56 'news' => array('left','right','__PAGE__'), 57 'notify' => array('left','right'), 58 'phpbrain' => array('__PAGE__'), 59 'redirect' => array('__PAGE__'), 60 'template' => array('left','right','__PAGE__'), 61 'validator' => array('footer'), 62 'wiki' => array('__PAGE__'), 63 ); 64 $dir = dir(EGW_SERVER_ROOT); 65 while(($app = $dir->read())) 66 { 67 $moddir = EGW_SERVER_ROOT . '/' . $app . ($app == 'sitemgr' ? '/modules' : '/sitemgr'); 68 if (is_dir($moddir)) 69 { 70 $d = dir($moddir); 71 while (($file = $d->read())) 72 { 73 if (preg_match ("/class\.module_(.*)\.inc\.php$/", $file, $module)) 74 { 75 $module = $module[1]; 76 77 if (ereg('\$this->description = lang\(\'([^'."\n".']*)\'\);',implode("\n",file($moddir.'/'.$file)),$parts)) 78 { 79 $description = $GLOBALS['egw_setup']->db->db_addslashes(str_replace("\\'","'",$parts[1])); 80 } 81 else 82 { 83 $description = ''; 84 } 85 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_modules (module_name,description) VALUES ('$module','$description')",__LINE__,__FILE__); 86 $id = $module_id[$module] = $oProc->m_odb->get_last_insert_id($sitemgr_table_prefix.'_modules','module_id'); 87 if (isset($areas[$module])) 88 { 89 foreach($areas[$module] as $area) 90 { 91 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_active_modules (area,cat_id,module_id) VALUES ('$area',$site_id,$id)",__LINE__,__FILE__); 92 } 93 } 94 } 95 } 96 $d->close(); 97 } 98 } 99 $dir->close(); 100 101 // create some sample categories for the site 102 foreach(array( 103 'other' => 'one more', 104 'sample' => 'sample category', 105 'sub-sample' => 'just a sub for sample' 106 ) as $name => $descr) 107 { 108 $parent = substr($name,0,4) == 'sub-' ? $cats[substr($name,4)] : $site_id; 109 $level = substr($name,0,4) == 'sub-' ? 2 : 1; 110 $oProc->query("INSERT INTO {$GLOBALS['egw_setup']->cats_table} (cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data,last_mod) VALUES ($site_id,$parent,$level,-1,'public','sitemgr','$name','$descr','0',".time().")"); 111 $cat_id = $cats[$name] = $oProc->m_odb->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); 112 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_categories_lang (cat_id,lang,name,description) VALUES ($cat_id,'en','$name','$descr')"); 113 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_categories_state (cat_id,state) VALUES ($cat_id,2)"); 114 foreach(array($admingroup => 3,$defaultgroup => 1,$anonymous => 1) as $account => $rights) 115 { 116 $GLOBALS['egw_setup']->add_acl('sitemgr',"L$cat_id",$account,$rights); 117 } 118 } 119 foreach(array( 120 'sample-page' => array($cats['sample'],'Sample page','just a sample', 121 )) as $name => $data) 122 { 123 list($cat_id,$title,$subtitle) = $data; 124 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_pages (cat_id,sort_order,hide_page,name,state) VALUES ($cat_id,0,0,'$name',2)"); 125 $page_id = $pages[$name] = $oProc->m_odb->get_last_insert_id($sitemgr_table_prefix.'_pages','page_id'); 126 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_pages_lang (page_id,lang,title,subtitle) VALUES ($page_id,'en','$title','$subtitle')"); 127 // please note: this pages have no own content so far, we add it in the following paragraph 128 } 129 130 // set up some site- and page-wide content 131 $visibility = array('all' => 0,'user' => 1,'admin' => 2,'anon' => 3); 132 foreach(array( 133 array($module_id['navigation'],'left',$site_id,0,$visibility['all'],'Root Site Index',NULL, 134 array('sub_cats' => 'on', 'nav_type' => 3)), 135 array($module_id['template'],'left',$site_id,0,$visibility['all'],'Choose template',NULL, 136 array('show' => 8, 'zip' => 'zip')), 137 array($module_id['navigation'],'right',$site_id,0,$visibility['all'],'Current Section',NULL, 138 array('nav_type' => 1)), 139 array($module_id['administration'],'right',$site_id,0,$visibility['admin'],'Administration'), 140 array($module_id['lang_block'],'right',$site_id,0,$visibility['all'],'Select language'), 141 array($module_id['calendar'],'right',$site_id,0,$visibility['user'],'Calendar'), 142 array($module_id['goggle'],'right',$site_id,0,$visibility['all'],'Goggle'), 143 array($module_id['login'],'right',$site_id,0,$visibility['anon'],'Login'), 144 array($module_id['amazon'],'right',$site_id,0,$visibility['all'],False,'Amazon.com',array('search' => 1)), 145 array($module_id['html'],'header',$site_id,0,$visibility['all'],'HTML Module', 146 array('htmlcontent' => '<h1>SiteMgr Demo</h1>')), 147 array($module_id['html'],'footer',$site_id,0,$visibility['all'],'HTML Module', 148 array('htmlcontent' => 'Powered by eGroupWare\'s <b>SiteMgr</b>. Please visit our Homepage <a href="http://www.egroupware.org" target="_blank">www.eGroupWare.org</a> and our <a href="http://www.sourceforge.net/projects/egroupware/" target="_blank">Sourceforge Project page</a>.')), 149 array($module_id['html'],'center',$cats['sample'],$pages['sample-page'],$visibility['all'],'HTML Module', 150 array('htmlcontent' => 'some sample <b>HTML</b> content ...')), 151 ) as $order => $block) 152 { 153 list($module,$area,$cat_id,$page_id,$visible,$title_en,$content_en,$content) = $block; 154 if (!$module) continue; 155 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_blocks (area,cat_id,page_id,module_id,sort_order,viewable) VALUES ('$area',$cat_id,$page_id,$module,$order,$visible)",__LINE__,__FILE__); 156 $block_id = $oProc->m_odb->get_last_insert_id($sitemgr_table_prefix.'_blocks','block_id'); 157 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_blocks_lang (block_id,lang,title) VALUES ($block_id,'en','$title_en')",__LINE__,__FILE__); 158 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_content (block_id,arguments,state) VALUES ($block_id,". 159 ($content ? $GLOBALS['egw_setup']->db->quote(serialize($content)) : 'NULL').",2)",__LINE__,__FILE__); 160 $version_id = $oProc->m_odb->get_last_insert_id($sitemgr_table_prefix.'_content','version_id'); 161 if ($content_en) 162 { 163 $oProc->query("INSERT INTO {$sitemgr_table_prefix}_content_lang (version_id,lang,arguments_lang) VALUES ($version_id,'en','".$GLOBALS['egw_setup']->db->db_addslashes(serialize($content_en))."')",__LINE__,__FILE__); 164 } 165 } 166 //echo "SiteMgr demo site installed<br>"; 167 168 // install sitemgr-link via symlink or copy (windows) 169 function cp_r($from,$to) 170 { 171 //echo "<p>cp_r($from,$to)<br>"; 172 if (is_file($from)) 173 { 174 //echo "copy($from,$to)<br>"; 175 if (is_dir($to)) 176 { 177 $to .= '/'.basename($from); 178 } 179 return copy($from,$to); 180 } 181 if (is_dir($from)) 182 { 183 $to .= '/'.basename($from); 184 if (!is_dir($to) && !mkdir($to)) 185 { 186 echo "Can't mkdir($to) !!!"; 187 return False; 188 } 189 if (!($dir = opendir($from))) 190 { 191 echo "Can't open $from !!!"; 192 return False; 193 } 194 while(($file = readdir($dir))) 195 { 196 if ($file != '.' && $file != '..') 197 { 198 if (!cp_r($from.'/'.$file,$to)) 199 { 200 return False; 201 } 202 } 203 } 204 } 205 return True; 206 } 207 208 if (!file_exists(EGW_SERVER_ROOT.'/sitemgr-link') && is_writable(EGW_SERVER_ROOT)) 209 { 210 chdir(EGW_SERVER_ROOT); 211 if (function_exists('symlink')) 212 { 213 symlink('sitemgr/sitemgr-link','sitemgr-link'); 214 echo "Symlink to sitemgr-link created and "; 215 } 216 else 217 { 218 // copy the whole dir for our windows friends ;-) 219 cp_r('sitemgr/sitemgr-link','.'); 220 echo "sitemgr/sitemgr-link copied to eGroupWare dir and "; 221 } 222 } 223 224 if (file_exists(EGW_SERVER_ROOT.'/sitemgr-link/setup/setup.inc.php')) 225 { 226 include(EGW_SERVER_ROOT.'/sitemgr-link/setup/setup.inc.php'); 227 $GLOBALS['setup_info']['sitemgr-link'] = $setup_info['sitemgr-link']; 228 $GLOBALS['egw_setup']->register_app('sitemgr-link'); 229 echo "sitemgr-link installed\n"; 230 } 231 else 232 { 233 echo "sitemgr-link NOT installed, you need to copy it from egroupware/sitemgr/sitemgr-link to egroupware/sitemgr-link and install it manually !!!"; 234 } 235
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |