Пример #1
0
 public function testWebResourceParameters()
 {
     include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
     $appender = new ilParameterAppender(999);
     $appender->setName('first');
     $appender->setValue(1);
     $appender->add(888);
     $params = ilParameterAppender::_getParams(888);
     foreach ($params as $key => $data) {
         $appender->delete($key);
         $this->assertEquals($data['name'], 'first');
         $this->assertEquals($data['value'], 1);
     }
 }
Пример #2
0
 /**
  * handler for begin of element
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  * @param	array		$a_attribs			element attributes array
  */
 public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
 {
     global $ilErr;
     if ($this->in_metadata) {
         parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
         return;
     }
     switch ($a_name) {
         case "MetaData":
             $this->in_metadata = true;
             // Delete old meta data
             $md = new ilMD($this->getWebLink()->getId(), 0, 'webr');
             $md->deleteAll();
             parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
             break;
         case 'WebLink':
             $this->current_link_update = false;
             $this->current_link_delete = false;
             $this->current_parameters = array();
             if ($this->getMode() == self::MODE_CREATE or isset($a_attribs['action']) and $a_attribs['action'] == 'Create') {
                 // New weblink
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
             } elseif ($this->getMode() == self::MODE_UPDATE and $a_attribs['action'] == 'Delete') {
                 $this->current_link_delete = true;
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
                 $this->current_link->delete($a_attribs['id']);
                 break;
             } elseif ($this->getMode() == self::MODE_UPDATE and ($a_attribs['action'] == 'Update' or !isset($a_attribs['action']))) {
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
                 $this->current_link->readItem($a_attribs['id']);
                 $this->current_link_update = true;
                 // Delete all dynamic parameter
                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
                 foreach (ilParameterAppender::getParameterIds($this->getWebLink()->getId(), $a_attribs['id']) as $param_id) {
                     $param = new ilParameterAppender($this->getWebLink()->getId());
                     $param->delete($param_id);
                 }
             } else {
                 throw new ilWebLinkXmlParserException('Invalid action given for element "Weblink"');
             }
             // Active
             $this->current_link->setActiveStatus($a_attribs['active'] ? 1 : 0);
             // Valid
             if (!isset($a_attribs['valid'])) {
                 $valid = 1;
             } else {
                 $valid = $a_attribs['valid'] ? 1 : 0;
             }
             $this->current_link->setValidStatus($valid);
             // Disable check
             $this->current_link->setDisableCheckStatus($a_attribs['disableValidation'] ? 1 : 0);
             break;
         case 'Sorting':
             include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
             $sort = new ilContainerSortingSettings($this->getWebLink()->getId());
             $sort->delete();
             switch ($a_attribs['type']) {
                 case 'Manual':
                     $sort->setSortMode(ilContainer::SORT_MANUAL);
                     break;
                 case 'Title':
                 default:
                     $sort->setSortMode(ilContainer::SORT_TITLE);
             }
             $sort->save();
             break;
         case 'WebLinks':
         case 'Title':
         case 'Description':
         case 'Target':
             // Nothing to do
             break;
         case 'DynamicParameter':
             $param = new ilParameterAppender($this->getWebLink()->getId());
             $param->setName($a_attribs['name']);
             switch ($a_attribs['type']) {
                 case 'userName':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_LOGIN);
                     $param->setValue(LINKS_LOGIN);
                     break;
                 case 'userId':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_USER_ID);
                     $param->setValue(LINKS_USER_ID);
                     break;
                 case 'matriculation':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_MATRICULATION);
                     $param->setValue(LINKS_MATRICULATION);
                     break;
                 default:
                     throw new ilWebLinkXmlParserException('Invalid attribute "type" given for element "Dynamic parameter". Aborting');
                     break;
             }
             $this->current_parameters[] = $param;
             break;
     }
 }
 protected function deleteParameterForm()
 {
     global $ilCtrl;
     $this->checkPermission('write');
     if (!isset($_GET['param_id'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'), TRUE);
         $ilCtrl->redirect($this, 'view');
     }
     include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
     $param = new ilParameterAppender($this->object->getId());
     $param->delete((int) $_GET['param_id']);
     ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'), true);
     $ilCtrl->redirect($this, 'view');
 }