Commits

Christian Kaula committed 4c3de5a

added setting page

  • Participants
  • Parent commits 238c434

Comments (0)

Files changed (1)

 		}
 	}
 
+	public function Base_GetAppSettingsMenuItems_Handler(&$Sender) {
+		$Menu = &$Sender->EventArguments['SideMenu'];
+		$Menu->AddItem('Forum', T('Forum'));
+		$Menu->AddLink(
+			'Forum', T('Global Notify'), 'settings/globalnotify',
+			'Garden.Settings.Manage'
+		);
+	}
+
 	public function PostController_AfterCommentSave_Handler(&$Sender) {
 		$Comment = $Sender->EventArguments['Comment'];
 		$Discussion = $Sender->EventArguments['Discussion'];
 		$Sender->Render($this->GetView('globalnotify.php'));
 	}
 
+	public function SettingsController_GlobalNotify_Create($Sender) {
+		$Sender->Permission('Garden.Settings.Manage');
+		$Sender->Title('Global Notify');
+		$Sender->AddSideMenu('settings/globalnotify');
+
+		$Validation = new Gdn_Validation();
+
+		$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
+
+		$host = C('Plugins.GlobalNotify.XMPP.Host', null);
+		$port = C('Plugins.GlobalNotify.XMPP.Port', 5222);
+		$user = C('Plugins.GlobalNotify.XMPP.User', null);
+		$pass = C('Plugins.GlobalNotify.XMPP.Pass', null);
+		$resource = C('Plugins.GlobalNotify.XMPP.Resource', 'xmppphp');
+
+		$ConfigArray = array(
+			'Plugins.GlobalNotify.XMPP.Host' => $host,
+			'Plugins.GlobalNotify.XMPP.Port' => $port,
+			'Plugins.GlobalNotify.XMPP.User' => $user,
+			'Plugins.GlobalNotify.XMPP.Pass' => $pass,
+			'Plugins.GlobalNotify.XMPP.Resource' => $resource
+		);
+		$ConfigurationModel->SetField($ConfigArray);
+
+
+		$Sender->Form->SetModel($ConfigurationModel);
+
+		if ($Sender->Form->AuthenticatedPostBack() === false) {
+			$Sender->Form->SetData($ConfigurationModel->Data);
+		} else {
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.Host', 'function:ValidateRequired');
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.Port', 'function:ValidateInteger');
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.Port', 'function:ValidateRequired');
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.User', 'function:ValidateRequired');
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.Pass', 'function:ValidateRequired');
+			$Sender->Form->ValidateRule('Plugins.GlobalNotify.XMPP.Resource', 'function:ValidateRequired');
+			$Sender->Form->Save();
+		}
+		$Sender->Render('plugins/GlobalNotify/views/settings.php');
+	}
+
 	public function Setup() {
 		// noop
 	}