This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Difference between revisions of "Extending settings with your own module"

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search
(Created page with "public static function submitSettings(&$settingsController, &$params, &$response, $user) { $settings = GO_Calendar_Model_Settings::model()->getDefault($user); if(!$setting...")
 
Line 1: Line 1:
 +
 +
<pre>
 
public static function submitSettings(&$settingsController, &$params, &$response, $user) {
 
public static function submitSettings(&$settingsController, &$params, &$response, $user) {
 
 
Line 16: Line 18:
 
return parent::submitSettings($settingsController, $params, $response, $user);
 
return parent::submitSettings($settingsController, $params, $response, $user);
 
}
 
}
+
</pre>
 +
<pre>
 
public static function loadSettings(&$settingsController, &$params, &$response, $user) {
 
public static function loadSettings(&$settingsController, &$params, &$response, $user) {
 
 
Line 35: Line 38:
 
return parent::loadSettings($settingsController, $params, $response, $user);
 
return parent::loadSettings($settingsController, $params, $response, $user);
 
}
 
}
 +
</pre>

Revision as of 09:36, 27 July 2012

public static function submitSettings(&$settingsController, &$params, &$response, $user) {
		
		$settings = GO_Calendar_Model_Settings::model()->getDefault($user);
		if(!$settings){
			$settings = new GO_Calendar_Model_Settings();
			$settings->user_id=$params['id'];
		}
		
		$settings->background=$params['background'];
		$settings->reminder=$params['reminder_multiplier'] * $params['reminder_value'];
		$settings->calendar_id=$params['default_calendar_id'];
	

		$settings->save();
		
		return parent::submitSettings($settingsController, $params, $response, $user);
	}
	
	public static function loadSettings(&$settingsController, &$params, &$response, $user) {
		
		$settings = GO_Calendar_Model_Settings::model()->getDefault($user);
		$response['data']=array_merge($response['data'], $settings->getAttributes());
		
		$calendar = GO_Calendar_Model_Calendar::model()->findByPk($settings->calendar_id);
		
		if($calendar){
			$response['data']['default_calendar_id']=$calendar->id;
			$response['remoteComboTexts']['default_calendar_id']=$calendar->name;
		}
		
		$response = GO_Calendar_Controller_Event::reminderSecondsToForm($response);
		
		
		
		return parent::loadSettings($settingsController, $params, $response, $user);
	}