root/taggingreloaded/files/lib/action/TaggingReloadedSaveAction.class.php @ 1091

Revision 1091, 2.1 kB (checked in by d0nut, 3 years ago)

possibly finished tagging version 0.8.2 - testing will follow

Line 
1<?php
2// wcf imports
3require_once(WCF_DIR.'lib/action/AbstractAction.class.php');
4
5/**
6 * ajax tagging
7 *
8 * @author      Torben Brodt
9 * @copyright   2009 TBR Solutions
10 * @license     commercial
11 * @package     de.easy-coding.wcf.taggingreloaded
12 */
13class TaggingReloadedSaveAction extends AbstractAction {
14        protected $taggable = '';
15        protected $className = '';
16        protected $classPath = '';
17        protected $entryKey = 'entryID';
18        protected $objectID = 0;
19        protected $languageID = 0;
20
21        /**
22         * @see Action::readParameters()
23         */
24        public function readParameters() {
25                parent::readParameters();
26               
27                $this->className = $_REQUEST['className'];
28                $this->classPath = $_REQUEST['classPath'];
29                $this->objectID = intval($_REQUEST['objectID']);
30               
31                if(isset($_REQUEST['entryKey'])) $this->entryKey = $_REQUEST['entryKey'];
32                if(isset($_REQUEST['languageID'])) $this->languageID = intval($_REQUEST['languageID']);
33                if(isset($_REQUEST['taggable'])) $this->taggable = $_REQUEST['taggable'];
34               
35                $this->tags3 = TaggingReloadedUtil::readFormParameters();
36        }
37       
38        /**
39         * @see Action::execute()
40         */
41        public function execute() {
42                parent::execute();
43               
44                if(!preg_match('/^Tagged/', $this->className) || preg_match('/\./', $this->className)) {
45                        throw new PermissionDeniedException();
46                }
47               
48                $classPath = WCF_DIR.'lib/data/'.$this->classPath.'/'.$this->className.'.class.php';
49               
50                if(preg_match('/\./', $this->classPath) || !file_exists($classPath)) {
51                        throw new PermissionDeniedException();
52                }
53               
54                require_once $classPath;
55               
56                $tagged = new $this->className(null, array(
57                        $this->entryKey => $this->objectID,
58                        'taggable' => TagEngine::getInstance()->getTaggable($this->taggable)
59                ));
60               
61                if(!($tagged instanceof Tagged)) {
62                        throw new PermissionDeniedException();
63                }
64               
65                $userID = WCF::getUser()->userID;
66               
67                $existingTagsUser = TaggingReloadedUtil::getTagsByObject($userID, $tagged, $this->languageID, true);
68                $existingTagsObject = TaggingReloadedUtil::getTagsByObject($userID, $tagged, $this->languageID, false);
69                TaggingReloadedUtil::tagging3save($userID, $tagged, $this->languageID, $this->tags3, $existingTagsUser, $existingTagsObject);
70               
71                $this->executed();
72        }
73}
74?>
Note: See TracBrowser for help on using the browser.