فهرست منبع

[svn r16418] Multiple URL feature implemented - require testing

Julio Montoya 16 سال پیش
والد
کامیت
5b61854e86
4فایلهای تغییر یافته به همراه359 افزوده شده و 70 حذف شده
  1. 128 18
      main/admin/settings.php
  2. 4 3
      main/inc/banner.inc.php
  3. 91 7
      main/inc/global.inc.php
  4. 136 42
      main/inc/lib/main_api.lib.php

+ 128 - 18
main/admin/settings.php

@@ -1,5 +1,5 @@
 <?php
-// $Id: settings.php 15849 2008-07-27 04:35:17Z yannoo $
+// $Id: settings.php 16418 2008-09-26 18:27:24Z juliomontoya $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -7,6 +7,7 @@
 	Copyright (c) 2004-2008 Dokeos SPRL
 	Copyright (c) 2003 Ghent University
 	Copyright (c) Patrick Cool, Ghent University
+	Copyright (c) Julio Montoya, Dokeos
 	Copyright (c) Roan Embrechts, Vrije Universiteit Brussel
 	Copyright (c) Bart Mollet, Hogeschool Gent
 
@@ -31,6 +32,7 @@
 *
 * @author Patrick Cool
 * @since Dokeos 1.6
+* @author Julio Montoya - Multiple URL site
 * @package dokeos.admin
 ==============================================================================
 */
@@ -81,7 +83,41 @@ if (!empty($_GET['category']) and $_GET['category'] <> "Plugins" and $_GET['cate
 	$renderer->setHeaderTemplate('<div class="settingtitle">{header}</div>'."\n");
 	$renderer->setElementTemplate('<div class="settingcomment">{label}</div>'."\n".'<div class="settingvalue">{element}</div>'."\n");
 	$my_category = mysql_real_escape_string($_GET['category']);
-	$settings = api_get_settings($my_category,'group',$_configuration['access_url']);
+	
+	if ($_configuration['access_url']==1)
+	{
+		$settings = api_get_settings($my_category,'group',$_configuration['access_url']);
+	}
+	else
+	{
+		$url_info = api_get_access_url($_configuration['access_url']);
+		if ($url_info['active']==1)
+		{
+			//the default settings of Dokeos
+			$settings = api_get_settings($my_category,'group',1,0);		
+			//the settings that are changeable from a particular site 
+			$settings_by_access = api_get_settings($my_category,'group',$_configuration['access_url'],1);			
+			//echo '<pre>';
+			//print_r($settings_by_access);
+			$settings_by_access_list=array();
+			foreach($settings_by_access as $row)
+			{
+				if (empty($row['variable']))
+					$row['variable']=0;
+				if (empty($row['subkey']))
+					$row['subkey']=0;
+				if (empty($row['category']))
+					$row['category']=0;
+				// one more validation if is changeable
+				if ($row['access_url_changeable']==1)
+					$settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]  = $row;
+				else
+					$settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]  = array();
+			}	
+		}
+	}
+
+	//print_r($settings_by_access_list);echo '</pre>';
 	//$sqlsettings = "SELECT DISTINCT * FROM $table_settings_current WHERE category='$my_category' GROUP BY variable ORDER BY id ASC";
 	//$resultsettings = api_sql_query($sqlsettings, __FILE__, __LINE__);
 	//while ($row = mysql_fetch_array($resultsettings))
@@ -89,14 +125,44 @@ if (!empty($_GET['category']) and $_GET['category'] <> "Plugins" and $_GET['cate
 	foreach($settings as $row)
 	{
 		$form->addElement('header', null, get_lang($row['title']));
+		$hideme=array();
+		$hide_element=false;
+		if ($_configuration['access_url']!=1)
+		{
+			if ($row['access_url_changeable']==0)
+			{
+				//we hide the element in other cases (checkbox, radiobutton) we 'freeze' the element
+				$hide_element=true;
+				$hideme=array('disabled');
+			}
+			elseif($url_info['active']==1)
+			{
+				// we show the elements 
+				if (empty($row['variable']))
+					$row['variable']=0;
+				if (empty($row['subkey']))
+					$row['subkey']=0;
+				if (empty($row['category']))
+					$row['category']=0;
+					
+				if (is_array ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]))
+				{
+					// we are sure that the other site have a selected value 
+					if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ]['selected_value']!='')											
+						$row['selected_value']	=$settings_by_access_list[$row['variable']] [$row['subkey']]	[ $row['category'] ]['selected_value'];
+				}
+				// there is no else because we load the default $row['selected_value'] of the main Dokeos site
+			}	
+		}	
+				
 		switch ($row['type'])
 		{
-			case 'textfield' :
-				$form->addElement('text', $row['variable'], get_lang($row['comment']));
+			case 'textfield' :						
+				$form->addElement('text', $row['variable'], get_lang($row['comment']),$hideme);
 				$default_values[$row['variable']] = $row['selected_value'];
 				break;
 			case 'textarea' :
-				$form->addElement('textarea', $row['variable'], get_lang($row['comment']));
+				$form->addElement('textarea', $row['variable'], get_lang($row['comment']),$hideme);
 				$default_values[$row['variable']] = $row['selected_value'];
 				break;
 			case 'radio' :
@@ -104,28 +170,34 @@ if (!empty($_GET['category']) and $_GET['category'] <> "Plugins" and $_GET['cate
 				$group = array ();
 				foreach ($values as $key => $value)
 				{
-					$group[] = $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
+					$element = & $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
+					if ($hide_element)
+						$element->freeze();
+					$group[] = $element; 
 				}
+				
 				$form->addGroup($group, $row['variable'], get_lang($row['comment']), '<br />', false);
 				$default_values[$row['variable']] = $row['selected_value'];
 				break;
 			case 'checkbox';
 				$sql = "SELECT * FROM settings_current WHERE variable='".$row['variable']."'";
 				$result = api_sql_query($sql, __FILE__, __LINE__);
-				$group = array ();
+				$group = array ();	
 				while ($rowkeys = mysql_fetch_array($result))
 				{
 					$element = & $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
 					if ($rowkeys['selected_value'] == 'true' && ! $form->isSubmitted())
 					{
-						$element->setChecked(true);
+						$element->setChecked(true); 
 					}
+					if ($hide_element)
+						$element->freeze();
 					$group[] = $element;
 				}
 				$form->addGroup($group, $row['variable'], get_lang($row['comment']), '<br />'."\n");
 				break;
 			case "link" :
-				$form->addElement('static', null, get_lang($row['comment']), get_lang('CurrentValue').' : '.$row['selected_value']);
+				$form->addElement('static', null, get_lang($row['comment']), get_lang('CurrentValue').' : '.$row['selected_value'],$hideme);
 		}
 	}
 	$form->addElement('submit', null, get_lang('Ok'));
@@ -194,6 +266,7 @@ if (isset ($_GET['category']))
 	switch ($_GET['category'])
 	{
 		// displaying the extensions: plugins
+		// this will be available to all the sites (access_urls)
 		case 'Plugins' :
 			handle_plugins();
 			break;
@@ -395,13 +468,29 @@ function display_plugin_cell($location, $plugin_info, $current_plugin, $active_p
 */
 function handle_stylesheets()
 {
+	global $_configuration;
 	// Current style
 	$currentstyle = api_get_setting('stylesheets');
-
-	// uploading a new stylesheet
-	echo '<a href="" id="stylesheetuploadlink" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
+	$is_style_changeable=false;
+	
+	if ($_configuration['access_url']!=1)
+	{
+		$style_info = api_get_settings('stylesheets','',1,0);
+		$url_info = api_get_access_url($_configuration['access_url']);	 
+		if ($style_info[0]['access_url_changeable']==1 && $url_info['active']==1)
+		{
+			$is_style_changeable=true;			
+			echo '<a href="" id="stylesheetuploadlink" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
+		} 
+	}
+	else
+	{
+		$is_style_changeable=true;
+		echo '<a href="" id="stylesheetuploadlink" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">'.get_lang('UploadNewStylesheet').'</a>';
+	}	
+		
 	$form = new FormValidator('stylesheet_upload','post','settings.php?category=stylesheets&showuploadform=true');
-	$form->addElement('text','name_stylesheet',get_lang('NameStylesheet'),array('size' => '40', 'maxlength' => '40'));
+	$form->addElement('text','name_stylesheet',get_lang('NameStylesheet'),array('size' => '40', 'maxlength' => '40'));	
 	$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
 	$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
 	$allowed_file_types = array ('css');
@@ -432,7 +521,18 @@ function handle_stylesheets()
 			{
 				echo '<div id="newstylesheetform" style="display: none;">';
 			}
-			$form->display();
+				// uploading a new stylesheet
+			if ($_configuration['access_url']==1)
+			{
+				$form->display();	
+			}
+			else
+			{
+				if ($is_style_changeable)
+				{
+					$form->display();				
+				}
+			}
 			echo '</div>';
 		}
 	}
@@ -464,8 +564,14 @@ function handle_stylesheets()
 						$selected = '';
 					}
 					$show_name=ucwords(str_replace('_',' ', $style_dir));
-					echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>";
-					echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
+					
+					if ($is_style_changeable)
+					{					
+						echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>";
+						echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
+					}
+					else
+						echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
 					//echo '<div id="Layer'.$counter.'" style="position:relative; width:687px; z-index:2; visibility: hidden;">';
 					//echo '<a href="#" onClick="MM_showHideLayers(\'Layer'.$counter.'\',\'\',\'hide\')">'.get_lang('Close').'</a>';
 					//echo '<iframe src="style_preview.php?style='.$file.'" width="100%" style="float:right;"></iframe></div>';
@@ -476,7 +582,10 @@ function handle_stylesheets()
 		}
 		@closedir($handle);
 	}
-	echo '<input type="submit" name="submit_stylesheets" value="'.get_lang('Ok').'" /></form>';
+	if ($is_style_changeable)
+	{	
+		echo '<input type="submit" name="submit_stylesheets" value="'.get_lang('Ok').'" /></form>';
+	}
 }
 
 /**
@@ -577,7 +686,8 @@ function store_stylesheets()
 
 		api_sql_query($sql, __LINE__, __FILE__);
 		*/
-		api_set_setting('stylesheets',$style,null,'stylesheets');
+		
+		api_set_setting('stylesheets',$style,null,'stylesheets',$_configuration['access_url']);
 	}
 
 	return true;

+ 4 - 3
main/inc/banner.inc.php

@@ -553,20 +553,21 @@ function get_tabs()
 	if(api_is_allowed_to_create_course() || $_user['status']==DRH)
 	{
 		// Link to my space
-		$navigation['session_my_space']['url'] = api_get_path(WEB_PATH).'main/mySpace/';
+		$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
 		$navigation['session_my_space']['title'] = get_lang('MySpace');
 	}
 	else
 	{
 		// Link to my progress
-		$navigation['session_my_progress']['url'] = api_get_path(WEB_PATH).'main/auth/my_progress.php';
+		$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
 		$navigation['session_my_progress']['title'] = get_lang('MyProgress');
 	}
 
 	// Platform administration
 	if (api_is_platform_admin(true))
 	{
-		$navigation['platform_admin']['url'] = $rootAdminWeb;
+		//$navigation['platform_admin']['url'] = $rootAdminWeb;
+		$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
 		$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
 	}
 

+ 91 - 7
main/inc/global.inc.php

@@ -180,19 +180,103 @@ else
 
 //$sql="SELECT * FROM settings_current";
 //$result=mysql_query($sql) or die(mysql_error());
-$result = api_get_settings(null,'list',$_configuration['access_url']);
+// access_url == 1 is the default dokeos location
+if ($_configuration['access_url']!=1)
+{	
+	$url_info = api_get_access_url($_configuration['access_url']);	
+	if ($url_info['active']==1)
+	{
+		$settings_by_access = api_get_settings(null,'list',$_configuration['access_url'],1);
+		foreach($settings_by_access as $row)
+		{
+			if (empty($row['variable']))
+				$row['variable']=0;
+			if (empty($row['subkey']))
+				$row['subkey']=0;
+			if (empty($row['category']))
+				$row['category']=0;					
+			$settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ]	[ $row['category'] ] = $row;		
+		}
+	}
+}
+
+//echo '<pre>';print_r($result_other_site);
+$result = api_get_settings(null,'list',1);
+
 //while ($row=mysql_fetch_array($result))
 foreach($result as $row)
-{
-	if ($row['subkey']==NULL)
+{	
+	if ($_configuration['access_url']!=1)
 	{
-		$_setting[$row['variable']]=$row['selected_value'];
+		if ($url_info['active']==1)
+		{
+			if (empty($row['variable']))
+				$var=0;
+			else
+				$var=$row['variable'];
+				
+			if (empty($row['subkey']))
+				$subkey=0;
+			else
+				$subkey=$row['subkey'];
+				
+			if (empty($row['category']))
+				$category=0;
+			else
+				$category=$row['category'];	
+		}
+		
+		if ($row['access_url_changeable']==1 && $url_info['active']==1)
+		{		
+			if ($settings_by_access_list[ $var ] [ $subkey ] [$category ]['selected_value'] !='')
+			{
+				if ($row['subkey']==NULL)
+				{
+					$_setting[$row['variable']]= $settings_by_access_list[ $var ] [ $subkey ] [$category ]['selected_value'];
+				}
+				else
+				{
+					$_setting[$row['variable']][$row['subkey']]=$settings_by_access_list[ $var ] [ $subkey ] [$category ]['selected_value'];
+				}
+			}
+			else
+			{
+				if ($row['subkey']==NULL)
+				{
+					$_setting[$row['variable']]=$row['selected_value'];
+				}
+				else
+				{
+					$_setting[$row['variable']][$row['subkey']]=$row['selected_value'];
+				}
+			}
+		}
+		else
+		{
+			if ($row['subkey']==NULL)
+			{
+				$_setting[$row['variable']]=$row['selected_value'];
+			}
+			else
+			{
+				$_setting[$row['variable']][$row['subkey']]=$row['selected_value'];
+			}
+		}
+		
 	}
 	else
-	{
-		$_setting[$row['variable']][$row['subkey']]=$row['selected_value'];
-	}
+	{			
+		if ($row['subkey']==NULL)
+		{
+			$_setting[$row['variable']]=$row['selected_value'];
+		}
+		else
+		{
+			$_setting[$row['variable']][$row['subkey']]=$row['selected_value'];
+		}		
+	}	
 }
+//echo '<pre>';print_r($_setting);echo '</pre>';
 // we have to store the settings for the plugins differently because it expects an array
 //$sql="SELECT * FROM settings_current WHERE category='plugins'";
 //$result=mysql_query($sql) or die(mysql_error());

+ 136 - 42
main/inc/lib/main_api.lib.php

@@ -6,6 +6,7 @@
 	Copyright (c) 2004-2008 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
+	Copyright (c) Julio Montoya
 	Copyright (c) Hugues Peeters
 	Copyright (c) Christophe Gesche
 	Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
@@ -306,20 +307,41 @@ function api_is_self_registration_allowed()
 */
 function api_get_path($path_type)
 {
-	global $_configuration;
-
+	global $_configuration;	
+	if ($_configuration['access_url']==1 || $_configuration['access_url']=='')
+	{
+		//by default we call the $_configuration['root_web'] we don't query to the DB
+		//$url_info= api_get_access_url(1);
+		//$root_web = $url_info['url'];		
+		$root_web = $_configuration['root_web'];
+	}
+	else
+	{
+		//we look into the DB the function api_get_access_url 
+		//this funcion have a problem because we can't called to the Database:: functions
+		$url_info= api_get_access_url($_configuration['access_url']);		
+		if ($url_info['active']==1)
+		{
+			$root_web = $url_info['url'];
+		}
+		else
+		{
+			$root_web = $_configuration['root_web'];
+		}
+	}
+	 
 	switch ($path_type)
 	{
 		case WEB_PATH :
 			// example: http://www.mydokeos.com/ or http://www.mydokeos.com/portal/ if you're using
 			// a subdirectory of your document root for Dokeos
-			if(substr($_configuration['root_web'],-1) == '/')
+			if(substr($root_web,-1) == '/')
 			{
-				return $_configuration['root_web'];
+				return $root_web;
 			}
 			else
 			{
-				return $_configuration['root_web'].'/';
+				return $root_web.'/';
 			}
 			break;
 
@@ -349,7 +371,7 @@ function api_get_path($path_type)
 
 		case WEB_COURSE_PATH :
 			// example: http://www.mydokeos.com/courses/
-			return $_configuration['root_web'].$_configuration['course_folder'];
+			return $root_web.$_configuration['course_folder'];
 			break;
 
 		case SYS_COURSE_PATH :
@@ -367,7 +389,8 @@ function api_get_path($path_type)
 			break;
 		case WEB_CODE_PATH :
 			// example: http://www.mydokeos.com/main/
-			return $GLOBALS['clarolineRepositoryWeb'];
+			//return $GLOBALS['clarolineRepositoryWeb']; // this was changed
+			return $root_web.$_configuration['code_append'];
 			break;
 		case SYS_CODE_PATH :
 			// example: /var/www/dokeos/main/
@@ -1288,7 +1311,7 @@ function api_is_coach()
 	global $_user;
 	global $sessionIsCoach;
 
-	$sql = "SELECT DISTINCT id, name, date_start, date_end
+	 $sql = "SELECT DISTINCT id, name, date_start, date_end
 							FROM session
 							INNER JOIN session_rel_course
 								ON session_rel_course.id_coach = '".mysql_real_escape_string($_user['user_id'])."'
@@ -2433,48 +2456,91 @@ function api_set_setting($var,$value,$subvar=null,$cat=null,$access_url=1)
 	else
 	{
 		$select .= " AND access_url = 1 ";
-	}
+	}	
 	$res = api_sql_query($select,__FILE__,__LINE__);
 	if(Database::num_rows($res)>0)
-	{ //found item for this access_url
+	{   //found item for this access_url
 		$row = Database::fetch_array($res);
-		$update = "UPDATE $t_settings SET selected_value = '$value' WHERE id = ".$row['id'];
+		$update = "UPDATE $t_settings SET selected_value = '$value' WHERE id = ".$row['id'] ;
 		$res = api_sql_query($update,__FILE__,__LINE__); 	
 	}
 	else
 	{ //item not found for this access_url, we have to check if the whole thing is missing 
 	  //(in which case we ignore the insert) or if there *is* a record but just for access_url=1
-		$select = "SELECT * FROM $t_settings WHERE variable = '$var' AND access_url = 1 ";
-		if(!empty($subvar))
-		{
-			$select .= " AND subkey = '$subvar'";
-		}
-		if(!empty($cat))
+		$select = "SELECT * FROM $t_settings WHERE variable = '$var' AND access_url = '1' ";
+		if ($access_url==1)
 		{
-			$select .= " AND category = '$cat'";
-		}
-		$res = api_sql_query($select,__FILE__,__LINE__);
-		if(Database::num_rows($select)>0)
-		{ //we have a setting for access_url 1, but none for the current one, so create one
-			$row = Database::fetch_array($res);
-			$insert = "INSERT INTO $t_settings " .
-					"(variable,subkey," .
-					"type,category," .
-					"selected_value,title," .
-					"comment,scope," .
-					"subkeytext,access_url)" .
-					" VALUES " .
-					"('".$row['variable']."',".(!empty($row['subkey'])?"'".$row['subkey']."'":"NULL")."," .
-					"'".$row['type']."','".$row['category']."'," .
-					"'$value','".$row['title']."'," .
-					"".(!empty($row['comment'])?"'".$row['comment']."'":"NULL").",'".(!empty($row['scope'])?"'".$row['scope']."'":"NULL")."'," .
-					"'".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL")."',$access_url)";
-			$res = api_sql_query($insert,__FILE__,__LINE__);
+			if(!empty($subvar))
+			{
+				$select .= " AND subkey = '$subvar'";
+			}
+			if(!empty($cat))
+			{
+				$select .= " AND category = '$cat'";
+			}	
+			$res = api_sql_query($select,__FILE__,__LINE__);
+			if(Database::num_rows($select)>0)
+			{ //we have a setting for access_url 1, but none for the current one, so create one
+				$row = Database::fetch_array($res);
+				echo $insert = "INSERT INTO $t_settings " .
+						"(variable,subkey," .
+						"type,category," .
+						"selected_value,title," .
+						"comment,scope," .
+						"subkeytext,access_url)" .
+						" VALUES " .
+						"('".$row['variable']."',".(!empty($row['subkey'])?"'".$row['subkey']."'":"NULL")."," .
+						"'".$row['type']."','".$row['category']."'," .
+						"'$value','".$row['title']."'," .
+						"".(!empty($row['comment'])?"'".$row['comment']."'":"NULL").",'".(!empty($row['scope'])?"'".$row['scope']."'":"NULL")."'," .
+						"'".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL")."',$access_url)";
+				$res = api_sql_query($insert,__FILE__,__LINE__);
+			}
+			else
+			{ // this setting does not exist
+				error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all',0);
+			}
 		}
 		else
-		{ // this setting does not exist
-			error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all',0);
-		}
+		{	
+			// other access url 
+			if(!empty($subvar))
+			{
+				$select .= " AND subkey = '$subvar'";
+			}
+			if(!empty($cat))
+			{
+				$select .= " AND category = '$cat'";
+			}
+			$res = api_sql_query($select,__FILE__,__LINE__);
+						
+			if(Database::num_rows($res)>0)
+			{ //we have a setting for access_url 1, but none for the current one, so create one				
+				$row = Database::fetch_array($res);
+				if ($row['access_url_changeable']==1)
+				{
+					$insert = "INSERT INTO $t_settings " .
+							"(variable,subkey," .
+							"type,category," .
+							"selected_value,title," .
+							"comment,scope," .
+							"subkeytext,access_url, access_url_changeable)" .
+							" VALUES " .
+							"('".$row['variable']."',".
+							(!empty($row['subkey'])?"'".$row['subkey']."'":"NULL")."," .
+							"'".$row['type']."','".$row['category']."'," .
+							"'$value','".$row['title']."'," .
+							"".(!empty($row['comment'])?"'".$row['comment']."'":"NULL").",".
+							(!empty($row['scope'])?"'".$row['scope']."'":"NULL")."," .
+							"'".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL")."',$access_url,".$row['access_url_changeable'].")";
+					$res = api_sql_query($insert,__FILE__,__LINE__);
+				}
+			}
+			else
+			{ // this setting does not exist
+				error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
+			}			
+		}	
 	}
 }
 /**
@@ -2526,6 +2592,28 @@ function api_get_access_urls($from=0,$to=1000000,$order='url',$direction='ASC')
 	}
 	return $result;
 }
+
+/**
+ * Get the access url info in an array
+ * @param 	id of the access url 
+ * @return	array Array with all the info (url, description, active, created_by, tms) from the access_url table 
+ * @author 	Julio Montoya Armas
+ */
+function api_get_access_url($id)
+{
+	global $_configuration;
+	$result = array();
+	// calling the Database:: library dont work this is handmade
+	//$table_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
+	$table='access_url';
+	$database = $_configuration['main_database'];
+	$table_access_url =  "`".$database."`.`".$table."`";	
+	$sql = "SELECT url, description, active, created_by, tms FROM $table_access_url WHERE id = '$id' ";	
+	$res = api_sql_query($sql,__FILE__,__LINE__);
+	$result = @mysql_fetch_array($res);
+	return $result;
+}
+
 /**
  * Adds an access URL into the database
  * @param	string	URL
@@ -2571,14 +2659,20 @@ function api_add_access_url($u,$d='',$a=1)
  * @param	int		Access URL's ID. Optional. Uses 1 by default, which is the unique URL
  * @return	array	Array of database results for the current settings of the current access URL
  */
-function api_get_settings($cat=null,$ordering='list',$access_url=1)
+function api_get_settings($cat=null,$ordering='list',$access_url=1,$url_changeable=0)
 {
 	$results = array();
 	$t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
 	$access_url = (int) $access_url;
+	
+	$url_changeable_where='';
+	if ($url_changeable==1)
+	{
+		$url_changeable_where= " AND access_url_changeable= '1' "; 
+	}	
 	if(empty($access_url)){$access_url=1;}
 	$sql = "SELECT id, variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable " .
-			" FROM $t_cs WHERE access_url = $access_url ";
+			" FROM $t_cs WHERE access_url = $access_url  $url_changeable_where ";
 	if(!empty($cat))
 	{
 		$cat = Database::escape_string($cat);
@@ -2591,7 +2685,7 @@ function api_get_settings($cat=null,$ordering='list',$access_url=1)
 	else
 	{
 		$sql .= " ORDER BY 1,2 ASC";
-	}
+	} 
 	$res = api_sql_query($sql,__FILE__,__LINE__);
 	if($res === false){return $results;}
 	$results = api_store_result($res);