public static function getGeneralSettingsForm()
 {
     global $lng;
     $form = new ilPropertyFormGUI();
     require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
     $channels = ilNotificationDatabaseHandler::getAvailableChannels(array(), true);
     $options = array('set_by_user' => $lng->txt('set_by_user'), 'set_by_admin' => $lng->txt('set_by_admin'));
     /**
      * @todo dirty...
      */
     $form->restored_values = array();
     $store_values = array();
     foreach ($channels as $channel) {
         $chb = new ilCheckboxInputGUI($lng->txt('enable_' . $channel['name']), 'enable_' . $channel['name']);
         $store_values[] = 'enable_' . $channel['name'];
         $select = new ilSelectInputGUI($lng->txt('config_type'), 'notifications[' . $channel['name'] . ']');
         $select->setOptions($options);
         $select->setValue($channel['config_type']);
         $chb->addSubItem($select);
         /**
          * @todo dirty...
          */
         $form->restored_values['notifications[' . $channel['name'] . ']'] = $channel['config_type'];
         require_once $channel['include'];
         // let the channel display their own settings below the "enable channel"
         // checkbox
         $result = call_user_func(array($channel['handler'], 'showSettings'), $chb);
         if ($result) {
             $store_values = array_merge($result, $store_values);
         }
         $form->addItem($chb);
     }
     /**
      * @todo dirty...
      */
     $form->store_values = $store_values;
     return $form;
 }
 public function showConfigMatrixObject()
 {
     global $ilTabs;
     $ilTabs->activateSubTab('notification_admin_matrix');
     require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
     require_once 'Services/Notifications/classes/class.ilNotificationSettingsTable.php';
     global $ilCtrl, $lng;
     $userdata = ilNotificationDatabaseHandler::loadUserConfig(-1);
     $table = new ilNotificationSettingsTable($this, 'a title', ilNotificationDatabaseHandler::getAvailableChannels(), $userdata, true);
     $table->setFormAction($ilCtrl->getFormAction($this, 'saveConfigMatrix'));
     $table->setData(ilNotificationDatabaseHandler::getAvailableTypes());
     $table->setDescription($lng->txt('notification_admin_matrix_settings_table_desc'));
     $table->addCommandButton('saveConfigMatrix', $lng->txt('save'));
     $table->addCommandButton('showConfigMatrix', $lng->txt('cancel'));
     $this->tpl->setContent($table->getHtml());
 }
 /**
  * Creates the user notifications and send them. If processAsync is true
  * the notifications will be serialized and persisted to the database
  * 
  * @param ilNotificationConfig $notification
  * @param type $users
  * @param type $processAsync 
  */
 private function toUsers(ilNotificationConfig $notification, $users, $processAsync = false)
 {
     require_once 'Services/Notifications/classes/class.ilNotificationUserIterator.php';
     require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
     // if async processing is disabled send them immediately
     if ($processAsync == false) {
         // loading the default configuration
         $adminConfig = ilNotificationDatabaseHandler::loadUserConfig(-1);
         $usersWithCustomConfig = ilNotificationDatabaseHandler::getUsersWithCustomConfig($users);
         // @todo this loop might be obsolet :)
         foreach ($users as $user_id) {
             if ($usersWithCustomConfig[$user_id]) {
                 /** @todo was ist hier? **/
             }
         }
         // load all available channels
         $channels = ilNotificationDatabaseHandler::getAvailableChannels();
         // load all available types
         $types = ilNotificationDatabaseHandler::getAvailableTypes();
         // preload translation vars
         $lang = ilNotificationDatabaseHandler::getTranslatedLanguageVariablesOfNotificationParameters($notification->getLanguageParameters());
         $user_by_handler = array();
         // check if the type allows custom user configurations for determining
         // the output channel (e.g. send chat notifications only via osd)
         if ($types[$notification->getType()]['config_type'] == 'set_by_user') {
             $it = new ilNotificationUserIterator($notification->getType(), $users);
             $channelsByAdmin = false;
             // add the user to each channel he configured in his own configuration
             foreach ($it as $usr_id => $data) {
                 // the configured user channel is (currently) not known
                 if (!$channels[$data['channel']]) {
                     continue;
                 }
                 if (!$user_by_handler[$data['channel']]) {
                     $user_by_handler[$data['channel']] = array();
                 }
                 $user_by_handler[$data['channel']][] = $usr_id;
             }
         } else {
             if ($types[$notification->getType()]['config_type'] != 'disabled') {
                 $channelsByAdmin = true;
                 //$user_by_handler = array();
                 if (isset($adminConfig[$notification->getType()])) {
                     foreach ($adminConfig[$notification->getType()] as $channel) {
                         if (!$channels[$channel]) {
                             continue;
                         }
                         $user_by_handler[$channel] = $users;
                     }
                 }
             }
         }
         $userCache = array();
         // process the notifications for each output channel
         foreach ($user_by_handler as $handler => $users) {
             $handler = $this->handler[$handler];
             // and process each user for the current output channel
             foreach ($users as $userId) {
                 if (!$userCache[$userId]) {
                     $userCache[$userId] = new ilObjUser($userId);
                 }
                 $user = $userCache[$userId];
                 // optain the message instance for the user
                 // @todo this step could be cached on a per user basis
                 //       as it is independed from the output handler
                 $instance = $notification->getUserInstance($user, $lang, $this->defaultLanguage);
                 foreach ($handler as $h) {
                     // fire the notification
                     $h->notify($instance);
                 }
             }
         }
     } else {
         // just enque the current configuration
         ilNotificationDatabaseHandler::enqueueByUsers($notification, $users);
     }
 }
Ejemplo n.º 4
0
 private function getAvailableChannels($types = array())
 {
     return ilNotificationDatabaseHandler::getAvailableChannels($types);
 }