Ejemplo n.º 1
0
    /**
     * move field
     */
    public function moveField()
    {
        if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_EDIT)) {
            return LogUtil::registerPermissionError();
        }

        $cid = (int)FormUtil::getPassedValue('cid', 0, 'GET');
        $dir = FormUtil::getPassedValue('direction', null, 'GET');
        $dr = (int)FormUtil::getPassedValue('dr', 0, 'GET');
        $url = System::serverGetVar('HTTP_REFERER');

        if (!$dr) {
            return LogUtil::registerError($this->__('Error! The document root is invalid.'), null, $url);
        }

        if (!$cid) {
            return LogUtil::registerError($this->__('Error! The category ID is invalid.'), null, $url);
        }

        if (!$dir) {
            return LogUtil::registerError($this->__f('Error! Invalid [%s] received.', 'direction'), null, $url);
        }

        $cats = CategoryUtil::getSubCategories($dr, false, false, false, false);
        $cats = CategoryUtil::resequence($cats, 10);
        $ak = array_keys($cats);
        foreach ($ak as $k) {
            $obj = new Categories_DBObject_Category($cats[$k]);
            $obj->update();
        }

        $data = array('id' => $cid);
        $val = ObjectUtil::moveField($data, 'categories_category', $dir, 'sort_value');

        $url = System::serverGetVar('HTTP_REFERER');
        $this->redirect($url);
    }
Ejemplo n.º 2
0
 /**
  * move field
  */
 public function moveFieldAction()
 {
     if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_EDIT)) {
         throw new \Zikula\Framework\Exception\ForbiddenException();
     }
     $cid = (int) $this->request->query->get('cid', 0);
     $dir = $this->request->query->get('direction', null);
     $dr = (int) $this->request->query->get('dr', 0);
     $url = System::serverGetVar('HTTP_REFERER');
     if (!$dr) {
         return LogUtil::registerError($this->__('Error! The document root is invalid.'), null, $url);
     }
     if (!$cid) {
         return LogUtil::registerError($this->__('Error! The category ID is invalid.'), null, $url);
     }
     if (!$dir) {
         return LogUtil::registerError($this->__f('Error! Invalid [%s] received.', 'direction'), null, $url);
     }
     $cats = CategoryUtil::getSubCategories($dr, false, false, false, false);
     $cats = CategoryUtil::resequence($cats, 10);
     $ak = array_keys($cats);
     foreach ($ak as $k) {
         $obj = new Category($cats[$k]);
         $obj->update();
     }
     $data = array('id' => $cid);
     $val = \ObjectUtil::moveField($data, 'categories_category', $dir, 'sort_value');
     $url = System::serverGetVar('HTTP_REFERER');
     return $this->redirect($url);
 }