public function copy() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADD)); $cid = $this->request->getPost()->get('cid'); $parent = $this->request->getPost()->get('parent'); $cat = new Categories_DBObject_Category(DBObject::GET_FROM_DB, $cid); $cat->copy($parent); $copyParent = new Categories_DBObject_Category(DBObject::GET_FROM_DB, $cat->getDataField('parent_id')); $categories = CategoryUtil::getSubCategories($copyParent->getDataField('id'), true, true, true, true, true); $options = array('nullParent' => $copyParent->getDataField('parent_id'), 'withWraper' => false); $node = CategoryUtil::getCategoryTreeJS((array) $categories, true, true, $options); $leafStatus = array('leaf' => array(), 'noleaf' => array()); foreach ($categories as $c) { if ($c['is_leaf']) { $leafStatus['leaf'][] = $c['id']; } else { $leafStatus['noleaf'][] = $c['id']; } } $result = array('action' => 'copy', 'cid' => $cid, 'copycid' => $copyParent->getDataField('id'), 'parent' => $copyParent->getDataField('parent_id'), 'node' => $node, 'leafstatus' => $leafStatus, 'result' => true); return new Zikula_Response_Ajax($result); }
/** * copy category */ public function copy() { $this->checkCsrfToken(); if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADD)) { return LogUtil::registerPermissionError(); } if (FormUtil::getPassedValue('category_cancel', null, 'POST')) { return System::redirect(ModUtil::url('Categories', 'admin', 'view')); } $cid = FormUtil::getPassedValue('cid', null, 'POST'); $cat = new Categories_DBObject_Category(); $cat->get($cid); $cat->copy($_POST['category']['parent_id']); $msg = __f('Done! Copied the %s category.', $cat->_objData['name']); LogUtil::registerStatus($msg); $this->redirect(ModUtil::url('Categories', 'admin', 'view')); }