示例#1
0
 function render()
 {
     # Validate proper permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_edit_settings, '');
     # Make sure the editresult is set to 'not comited' per default
     $result = new Dto_FormResult('notsubmitted');
     # set the page title
     $this->_pageTitle = _('Settings');
     /* 
      * bring the forms' action into the local scope for 
      * easier access
      */
     $formAction = $this->_editSettingsForm['action'];
     # Are we trying to submit this form, or only rendering it?
     if (!empty($formAction)) {
         switch ($formAction) {
             case 'edit':
                 # Validate and apply all settings
                 $svcSettings = new Services_Settings_Base($this->_settings, $this->_daoFactory->getBlackWhiteListDao());
                 $result = $svcSettings->validateSettings($this->_editSettingsForm);
                 if ($result->isSuccess()) {
                     # and actually update the user in the database
                     $newSettings = $result->getData('settings');
                     $svcSettings->setSettings($newSettings);
                 }
                 # if
                 break;
                 # case 'edit'
             # case 'edit'
             case 'cancel':
                 $result = new Dto_FormResult('success');
                 # case 'cancel'
         }
         # switch
     }
     # if
     #- display stuff -#
     $this->template('editsettings', array('editsettingsform' => $this->_settings, 'result' => $result, 'http_referer' => $this->_editSettingsForm['http_referer']));
 }
示例#2
0
 private function validate(Services_Settings_Base $settings)
 {
     /*
      * The basics has been setup, lets check if the schema needs
      * updating
      */
     if (!$settings->schemaValid()) {
         throw new SchemaNotUpgradedException();
     }
     # if
     /*
      * Does our global setting table need updating? 
      */
     if (!$settings->settingsValid()) {
         throw new SettingsNotUpgradedException();
     }
     # if
     /*
      * Because users are asked to modify ownsettings.php themselves, it is 
      * possible they create a mistake and accidentally create output from it.
      *
      * This output breaks a lot of stuff like download integration, image generation
      * and more.
      *
      * We try to check if any output has been submitted, and if so, we refuse
      * to continue to prevent all sorts of confusing bug reports
      */
     if (headers_sent() || (int) ob_get_length() > 0) {
         throw new OwnsettingsCreatedOutputException();
     }
     # if
 }
示例#3
0
 function sendMessages($userId)
 {
     $userDao = $this->_daoFactory->getUserDao();
     $notificationDao = $this->_daoFactory->getNotificationDao();
     if ($userId == 0) {
         $userList = $userDao->getUserList();
     } else {
         $thisUser = $userDao->getUser($userId);
         $userList = array($thisUser);
     }
     # else
     foreach ($userList as $user) {
         # Omdat we vanuit getUserList() niet alle velden meekrijgen
         # vragen we opnieuw het user record op
         $user = $userDao->getUser($user['userid']);
         $security = new SpotSecurity($this->_daoFactory->getUserDao(), $this->_daoFactory->getAuditDao(), $this->_settings, $user, '');
         # Om e-mail te kunnen versturen hebben we iets meer data nodig
         $user['prefs']['notifications']['email']['sender'] = $this->_settings->get('systemfrommail');
         $user['prefs']['notifications']['email']['receiver'] = $user['mail'];
         # Twitter heeft ook extra settings nodig
         $user['prefs']['notifications']['twitter']['consumer_key'] = $this->_settings->get('twitter_consumer_key');
         $user['prefs']['notifications']['twitter']['consumer_secret'] = $this->_settings->get('twitter_consumer_secret');
         # Evenals Boxcar
         $user['prefs']['notifications']['boxcar']['api_key'] = $this->_settings->get('boxcar_api_key');
         $user['prefs']['notifications']['boxcar']['api_secret'] = $this->_settings->get('boxcar_api_secret');
         $newMessages = $notificationDao->getUnsentNotifications($user['userid']);
         foreach ($newMessages as $newMessage) {
             $objectId = $newMessage['objectid'];
             $spotweburl = $this->_settings->get('spotweburl') == 'http://mijnuniekeservernaam/spotweb/' ? '' : $this->_settings->get('spotweburl');
             $notifProviders = Notifications_Factory::getActiveServices();
             foreach ($notifProviders as $notifProvider) {
                 if ($user['prefs']['notifications'][$notifProvider]['enabled'] && $user['prefs']['notifications'][$notifProvider]['events'][$objectId]) {
                     if ($security->allowed(SpotSecurity::spotsec_send_notifications_services, $notifProvider)) {
                         $this->_notificationServices[$notifProvider] = Notifications_Factory::build('Spotweb', $notifProvider, $user['prefs']['notifications'][$notifProvider]);
                     }
                     # if
                 }
                 # if
             }
             # foreach
             # nu wordt het bericht pas echt verzonden
             foreach ($this->_notificationServices as $notificationService) {
                 $notificationService->sendMessage($newMessage['type'], utf8_decode($newMessage['title']), utf8_decode($newMessage['body']), $spotweburl);
             }
             # foreach
             # Alle services resetten, deze mogen niet hergebruikt worden
             $this->_notificationServices = array();
             # Als dit bericht ging over het aanmaken van een nieuwe user, verwijderen we
             # het plaintext wachtwoord uit de database uit veiligheidsoverwegingen.
             if ($objectId == SpotNotifications::notifytype_user_added) {
                 $body = explode(" ", $newMessage['body']);
                 $body[4] = '[deleted]';
                 $newMessage['body'] = implode(" ", $body);
             }
             # if
             $newMessage['sent'] = true;
             $notificationDao->updateNotification($newMessage);
         }
         # foreach message
     }
     # foreach user
 }