/** * getModelFolders * @return Model_Folders * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ protected function getModelFolders() { if (null === $this->objModelFolders) { /** * autoload only handles "library" compoennts. * Since this is an application model, we need to require it * from its modules path location. */ require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Folders.php'; $this->objModelFolders = new Model_Folders(); $this->objModelFolders->setLanguageId($this->core->intZooluLanguageId); } return $this->objModelFolders; }
/** * save * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function save() { $this->core->logger->debug('massiveart->generic->data->GenericDataTypeFolder->save()'); try { $this->getModelFolders()->setLanguageId($this->setup->getLanguageId()); $intUserId = Zend_Auth::getInstance()->getIdentity()->id; /** * add|edit|newVersion core and instance data */ switch ($this->setup->getActionType()) { case $this->core->sysConfig->generic->actions->add: $strFolderId = uniqid(); $intFolderVersion = 1; $intSortPosition = GenericSetup::DEFAULT_SORT_POSITION; if ($this->setup->getParentId() != '' && $this->setup->getParentId() > 0) { $objNaviData = $this->getModelFolders()->loadChildNavigation($this->setup->getParentId()); } else { $objNaviData = $this->getModelFolders()->loadRootNavigation($this->setup->getRootLevelId()); } $intSortPosition = count($objNaviData); $arrMainData = array('idGenericForms' => $this->setup->getGenFormId(), 'idFolderTypes' => $this->core->sysConfig->folder_types->folder, 'folderId' => $strFolderId, 'version' => $intFolderVersion, 'sortPosition' => $intSortPosition, 'sortTimestamp' => date('Y-m-d H:i:s'), 'idUsers' => $intUserId, 'creator' => $this->setup->getCreatorId(), 'created' => date('Y-m-d H:i:s'), 'idStatus' => $this->setup->getStatusId(), 'isUrlFolder' => $this->setup->getUrlFolder(), 'showInNavigation' => $this->setup->getShowInNavigation()); /** * add folder node to the "Nested Set Model" */ $this->setup->setElementId($this->objModelFolders->addFolderNode($this->setup->getRootLevelId(), $this->setup->getParentId(), $arrMainData)); $this->insertCoreData('folder', $strFolderId, $intFolderVersion); $this->insertInstanceData('folder', array('Id' => $strFolderId, 'Version' => $intFolderVersion)); break; case $this->core->sysConfig->generic->actions->edit: $objSelect = $this->objModelFolders->getFolderTable()->select(); $objSelect->from('folders', array('folderId', 'version')); $objSelect->where('id = ?', $this->setup->getElementId()); $objRowSet = $this->objModelFolders->getFolderTable()->fetchAll($objSelect); if (count($objRowSet) == 1) { $objFolder = $objRowSet->current(); $strWhere = $this->objModelFolders->getFolderTable()->getAdapter()->quoteInto('folderId = ?', $objFolder->folderId); $strWhere .= $this->objModelFolders->getFolderTable()->getAdapter()->quoteInto(' AND version = ?', $objFolder->version); $this->core->logger->debug('save(): creator: ' . $this->setup->getCreatorId() . ' - idStatus: ' . $this->setup->getStatusId() . ' - isUrlFolder: ' . $this->setup->getUrlFolder()); $this->objModelFolders->getFolderTable()->update(array('idUsers' => $intUserId, 'creator' => $this->setup->getCreatorId(), 'idStatus' => $this->setup->getStatusId(), 'isUrlFolder' => $this->setup->getUrlFolder(), 'showInNavigation' => $this->setup->getShowInNavigation(), 'changed' => date('Y-m-d H:i:s')), $strWhere); $this->updateCoreData('folder', $objFolder->folderId, $objFolder->version); $this->updateInstanceData('folder', $objFolder->folderId, $objFolder->version); } break; } return $this->setup->getElementId(); } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * getModelFiles * @return Model_Files * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ protected function getModelFiles() { if (null === $this->objModelFiles) { require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Files.php'; $this->objModelFiles = new Model_Files(); $this->objModelFiles->setLanguageId(1); // TODO : get language id } return $this->objModelFiles; }
* @copyright Copyright (c) 2008-2009 HID GmbH (http://www.hid.ag) * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, Version 3 * @version $Id: version.php */ define('APPLICATION_ENV', 'development'); /** * include general (autoloader, config) */ require_once dirname(__FILE__) . '/../sys_config/general.inc.php'; try { $objConsoleOpts = new Zend_Console_Getopt(array('folderId|f=i' => 'Folder Id', 'rootLevelId|r=i' => 'RootLevel Id', 'fromLanguageId|fl=i' => 'From Language Id', 'toLanguageId|tl=i' => 'To Language Id')); echo "build tree language variant\n---------------------------\n"; if (isset($objConsoleOpts->fromLanguageId) && isset($objConsoleOpts->toLanguageId)) { echo "load fist level of the tree ...\n"; require_once GLOBAL_ROOT_PATH . $core->sysConfig->path->zoolu_modules . 'core/models/Folders.php'; $objModelFolders = new Model_Folders(); $objModelFolders->setLanguageId($objConsoleOpts->fromLanguageId); if (isset($objConsoleOpts->folderId) && $objConsoleOpts->folderId > 0) { $objProducts = $objModelFolders->loadGlobalChildNavigation($objConsoleOpts->folderId, $core->sysConfig->root_level_groups->product); } else { if (isset($objConsoleOpts->rootLevelId) && $objConsoleOpts->rootLevelId > 0) { $objProducts = $objModelFolders->loadGlobalRootNavigation($objConsoleOpts->rootLevelId, $core->sysConfig->root_level_groups->product); } } // simulate user auth $obj = new stdClass(); $obj->id = 3; //user id Zend_Auth::getInstance()->getStorage()->write($obj); if (isset($objProducts) && count($objProducts)) { buildTreeLanguageVariantNow($objProducts);
/** * addRootLevelsToAcl * @param Model_Folders $objModelFolders * @param integer $intModuleId * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function addRootLevelsToAcl(Model_Folders $objModelFolders, $intModuleId, $intZoneId = self::ZONE_ZOOLU) { try { /** * add resources & groups & privileges */ $arrResources = $objModelFolders->getRootLevelsPermissions($intModuleId, $intZoneId); foreach ($arrResources as $objResource) { // check if acel for this zone exists if (!array_key_exists('id_' . $objResource->zone, $this->arrZoneAcls) || !$this->arrZoneAcls['id_' . $objResource->zone] instanceof Acl) { $this->arrZoneAcls['id_' . $objResource->zone] = new Acl(); } $strResourceId = $objResource->languageId == 0 ? Security::RESOURCE_ROOT_LEVEL_PREFIX . $objResource->id : Security::RESOURCE_ROOT_LEVEL_PREFIX . $objResource->id . '_' . $objResource->languageId; if (!$this->arrZoneAcls['id_' . $objResource->zone]->has($strResourceId)) { $this->arrZoneAcls['id_' . $objResource->zone]->add(new Zend_Acl_Resource($strResourceId)); } if (!$this->arrZoneAcls['id_' . $objResource->zone]->hasRole($objResource->groupKey)) { $this->arrZoneAcls['id_' . $objResource->zone]->addRole(new Zend_Acl_Role($objResource->groupKey)); } $this->arrZoneAcls['id_' . $objResource->zone]->allow($objResource->groupKey, $strResourceId, $objResource->permissionTitle); } } catch (Exception $exc) { Zend_Registry::get('Core')->logger->err($exc); } }