[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: class.Pages_BO.inc.php 20295 2006-02-15 12:31:25Z $ */ 13 14 class Pages_BO 15 { 16 var $so; 17 18 function Pages_BO() 19 { 20 $this->so =& CreateObject('sitemgr.Pages_SO',True); 21 } 22 23 function getPageOptionList($cats=0,$index='Show Site Index',$state='Production') 24 { 25 $pagelist = $this->so->getPageIDList($cats,$GLOBALS['Common_BO']->getstates($state)); 26 if ($index) 27 { 28 $retval[]=array('value'=>0,'display'=>'[' .lang(/*'Show Site Index'*/$index) . ']'); 29 } 30 foreach($pagelist as $page_id) 31 { 32 $page = $this->so->getPage($page_id); 33 $retval[]=array('value'=>$page_id,'display'=>$page->name.' - '.$page->title); 34 } 35 return $retval; 36 } 37 38 function getpageIDListCommitable() 39 { 40 //only retrieve commitable pages from writeable categories 41 return $this->so->getPageIDList($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Commit')); 42 } 43 44 function getpageIDListArchived() 45 { 46 //only retrieve archived pages from writeable categories 47 return $this->so->getPageIDList($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Archive')); 48 } 49 50 function getPageIDList($cat_id=0,$states=false) 51 { 52 return $this->so->getPageIDList($cat_id,$states); 53 } 54 55 function addPage($cat_id) 56 { 57 if ($GLOBALS['Common_BO']->acl->can_write_category($cat_id)) 58 { 59 return $this->so->addPage($cat_id); 60 } 61 else 62 { 63 return false; 64 } 65 } 66 67 function removePagesInCat($cat_id,$force=False) 68 { 69 if (!($force || $GLOBALS['Common_BO']->acl->can_write_category($cat_id))) 70 { 71 return false; 72 } 73 $pages = $this->so->getPageIDList($cat_id); 74 while(list(,$page_id) = each($pages)) 75 { 76 $this->removePage($page_id,True); 77 } 78 } 79 80 function removePage($page_id,$force=False) 81 { 82 $cat_id = $this->so->getcatidforpage($page_id); 83 if (!$force) 84 { 85 if (!$GLOBALS['Common_BO']->acl->can_write_category($cat_id)) 86 { 87 return false; 88 } 89 } 90 $this->so->removePage($page_id); 91 //since we already did the ACL we force 92 $GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,$page_id,True); 93 } 94 95 function getPage($page_id,$lang=False,$force=False) 96 { 97 $page = $this->so->getPage($page_id,$lang); 98 if ($page && in_array($page->cat_id,$GLOBALS['Common_BO']->cats->readablecats)) 99 { 100 //if the page is not in published status we maintain its name so that switching from edit to prodcution mode works 101 if (!in_array($page->state,$GLOBALS['Common_BO']->visiblestates) && !$force) 102 { 103 $page->title = lang('Error accessing page'); 104 $page->subtitle = ''; 105 $page->id = 0; 106 $page->cat_id = 0; 107 } 108 return $page; 109 } 110 else 111 { 112 $page =& CreateObject('sitemgr.Page_SO'); 113 $page->name = 'Error'; 114 $page->title = lang('Error accessing page'); 115 $page->subtitle = ''; 116 // $page->content = lang('There was an error accessing the requested page. Either you do not have permission to view this page, or the page does not exist.'); 117 return $page; 118 } 119 } 120 121 function getlangarrayforpage($page_id) 122 { 123 return $this->so->getlangarrayforpage($page_id); 124 } 125 126 function savePageInfo($page_Info,$lang) 127 { 128 $oldpage = $this->getpage($page_Info->id); 129 130 if(!($GLOBALS['Common_BO']->acl->can_write_category($page_Info->cat_id) && 131 $GLOBALS['Common_BO']->acl->can_write_category($oldpage->cat_id))) 132 { 133 return lang("You don't have permission to write to that category."); 134 } 135 136 $fixed_name = strtr($page_Info->name, '!@#$%^&*()=+ /?><,.\\\'":;|`~{}[]',' '); 137 $fixed_name = str_replace(' ', '', $fixed_name); 138 if ($fixed_name != $page_Info->name) 139 { 140 $page_Info->name = $fixed_name; 141 $this->so->savePageInfo($page_Info); 142 $this->so->savePageLang($page_Info,$lang); 143 $this->NotifyUsers($lang, $page_Info->id,$page_Ingo->cat_id,$page_Info->state,$page_Info->name); 144 return lang('The Name field cannot contain punctuation or spaces (field modified).'); 145 } 146 147 if ($this->so->pageExists($page_Info->name,$page_Info->id)) 148 { 149 $page_Info->name .= '--FIX-DUPLICATE-NAME'; 150 $this->so->savePageInfo($page_Info); 151 $this->so->savePageLang($page_Info,$lang); 152 $this->NotifyUsers($lang, $page_Info->id,$page_Ingo->cat_id,$page_Info->state,$page_Info->name); 153 return lang('The page name must be unique.'); 154 } 155 $this->so->savePageInfo($page_Info); 156 $this->so->savePageLang($page_Info,$lang); 157 $this->NotifyUsers($lang, $page_Info->id,$page_Info->cat_id,$page_Info->state,$page_Info->name); 158 return True; 159 } 160 161 function savePageLang($page_Info,$lang) 162 { 163 $this->so->savePageLang($page_Info,$lang); 164 $this->NotifyUsers($lang, $page_Info->id,$page_Info->cat_id,$page_Info->state,$page_Info->name); 165 } 166 167 function removealllang($lang) 168 { 169 $this->so->removealllang($lang); 170 } 171 172 function migratealllang($oldlang,$newlang) 173 { 174 $this->so->migratealllang($oldlang,$newlang); 175 } 176 177 function commit($page_id) 178 { 179 $cat_id = $this->so->getcatidforpage($page_id); 180 if ($GLOBALS['Common_BO']->acl->can_write_category($cat_id)) 181 { 182 $this->so->commit($page_id); 183 } 184 } 185 186 function reactivate($page_id) 187 { 188 $cat_id = $this->so->getcatidforpage($page_id); 189 if ($GLOBALS['Common_BO']->acl->can_write_category($cat_id)) 190 { 191 $this->so->reactivate($page_id); 192 } 193 } 194 195 function NotifyUsers($lang, $page_id, $cat_id, $state, $page_name) 196 { 197 if (empty($cat_id)||(state<0)) { 198 $pso=CreateObject("sitemgr.Pages_SO"); 199 $pg=$pso->getPage($page_id); 200 $cat_id=$pg->$cat_id; 201 $state=$pg->state; 202 } 203 204 $bo=CreateObject("sitemgr.notification_bo"); 205 $bo->notify_users($GLOBALS['Common_BO']->sites->current_site['site_id'], 206 $cat_id, 207 $state, 208 $lang, 209 $GLOBALS['Common_BO']->sites->current_site['sitelanguages']['0'], 210 array('page_id'=>$page_id,'lang'=>$lang), 211 array( 212 array('text'=>"Page name:",'translate'=>True), 213 " ",$page_name 214 ) 215 ); 216 } 217 } 218 ?>
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 |