| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author Arthur Schiwon <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license GNU AGPL version 3 or any later version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This program is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * it under the terms of the GNU Affero General Public License as | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * published by the Free Software Foundation, either version 3 of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * You should have received a copy of the GNU Affero General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | namespace OC\Settings\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use OC\Share\Share; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use OCP\AppFramework\Http\TemplateResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use OCP\IConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use OCP\Settings\ISettings; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use OCP\Util; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | class Sharing implements ISettings { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	/** @var IConfig */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	private $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 * @param IConfig $config | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 38 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	public function __construct(IConfig $config) { | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 		$this->config = $config; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	 * @return TemplateResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function getForm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		$excludeGroupsList = !is_null(json_decode($excludedGroups)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			? implode('|', json_decode($excludedGroups, true)) : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$parameters = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 			// Built-In Sharing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 			'allowGroupSharing'               => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			'allowLinks'                      => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			'allowMailNotification'           => $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			'allowPublicMailNotification'     => $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 			'allowPublicUpload'               => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			'allowResharing'                  => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 			'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			'enforceLinkPassword'             => Util::isPublicLinkPasswordRequired(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			'onlyShareWithGroupMembers'       => Share::shareWithGroupMembersOnly(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			'shareAPIEnabled'                 => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			'shareDefaultExpireDateSet'       => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			'shareExpireAfterNDays'           => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			'shareEnforceExpireDate'          => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			'shareExcludeGroups'              => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			'shareExcludedGroupsList'         => $excludeGroupsList, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		return new TemplateResponse('settings', 'admin/sharing', $parameters, ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * @return string the section ID, e.g. 'sharing' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	public function getSection() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		return 'sharing'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 * @return int whether the form should be rather on the top or bottom of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 * the admin section. The forms are arranged in ascending order of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 * priority values. It is required to return a value between 0 and 100. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	 * E.g.: 70 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	public function getPriority() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 90 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |  |