示例#1
0
 /**
  * Create UserOptions object saving Request with session data
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     $this->container = $request->getContainer('pazpar2options');
     if ($request->getParam('sourcetype') != '') {
         $this->setSessionData('source_type', $request->getParam('sourcetype'));
         // if changing sourcetype, clear all old target selections
         $this->unsetSessionData('selectedby');
     } else {
         if (!$this->existsInSessionData('source_type')) {
             $config = Config::getInstance();
             $this->setSessionData('source_type', $config->getDefaultSourceType());
         }
     }
     // if this is a submit, change the session values as required
     if ($request->getParam('changetargets') != '') {
         $selectedby = $request->getParam('selectedby');
         if ($selectedby == 'names') {
             $targets = $request->getParam('target', null, true);
             $this->setSessionData('names', $targets);
             $this->setSessionData('selectedby', $selectedby);
         } else {
             if ($selectedby == 'subjects') {
                 $subjects = $request->getParam('subject', null, true);
                 $this->setSessionData('subjects', $subjects);
                 $this->setSessionData('selectedby', $selectedby);
             } else {
                 if ($selectedby == 'entitlements') {
                     $entitlements = $request->getParam('entitlement', null, true);
                     $this->setSessionData('entitlements', $entitlements);
                     $this->setSessionData('selectedby', $selectedby);
                 }
             }
         }
     }
     // retrieve the session values
     // set the actual targets to use
     if ($this->existsInSessionData('selectedby')) {
         $key = $this->getSessionData('selectedby');
     } else {
         $this->setSessionData('selectedby', 'names');
         $this->setSessionData('names', array('all'));
         $key = 'names';
     }
     $this->calculateTargets($key, $this->getSessionData($key), $this->getSessionData('source_type'));
 }