public function executeModuleRecursive(dmModule $module, dmTableLoremizer $loremizer) { $loremizer->execute($module->getTable()); foreach ($module->getChildren() as $child) { $this->executeModuleRecursive($child, $loremizer); } }
protected function writeFixture(dmModule $module, $securityDesc) { $this->clear(); if ($pluginName = $module->getPluginName()) { $root = dmContext::getInstance()->getConfiguration()->getPluginConfiguration($pluginName)->getRootDir(); } else { $root = sfConfig::get('sf_root_dir'); } $fixturesRootPath = dmOs::join($root, 'data', 'fixtures'); foreach (array('admin', 'front') as $app) { foreach (array('actions', 'components') as $actionKind) { if (isset($securityDesc[$app]) && isset($securityDesc[$app][$actionKind]) && is_array($securityDesc[$app][$actionKind])) { foreach ($securityDesc[$app][$actionKind] as $actionName => $actionDesc) { if (isset($actionDesc['credentials'])) { $credentials = (array) $module->getSecurityManager()->parseCredentials($actionDesc['credentials']); foreach ($credentials as $credential) { $this->addPermissionFor($credential, $module->getKey(), $actionName); } } } } } } $this->doWriteFixture(dmOs::join($fixturesRootPath, 'DmPermissions', $module->getKey() . '.yml')); }
public function clearModule(dmModule $module) { try { $module->getTable()->createQuery()->delete()->execute(); } catch (Exception $e) { $t->diag(sprintf('Can not delete %s records : %s', $module, $e->getMessage())); } foreach ($module->getTable()->getRelationHolder()->getAssociations() as $alias => $association) { $association['refTable']->createQuery()->delete()->execute(); } }
/** * @param string $app * @param string $actionKind * @param string $action * @return mixed false||array */ public function getSecurityConfiguration($app = null, $actionKind = null, $action = null) { $security = $this->module->getOption('security'); if (null === $app) { return $security; } $security = isset($security[$app]) ? $security[$app] : false; if (!$security) { $credentials = $this->module->getOption('credentials'); return array('strategy' => 'action', 'credentials' => $credentials, 'is_secure' => !empty($credentials)); } if (null === $actionKind) { return $security; } else { $security = isset($security[$actionKind]) ? $security[$actionKind] : false; } if (!$security) { return false; } if (null === $action) { return $security; } else { return isset($security[$action]) ? $security[$action] : false; } return false; }
protected function addFixtures(dmModule $module, $securityDesc) { foreach (array('admin', 'front') as $app) { foreach (array('actions', 'components') as $actionKind) { if (isset($securityDesc[$app]) && isset($securityDesc[$app][$actionKind]) && is_array($securityDesc[$app][$actionKind])) { foreach ($securityDesc[$app][$actionKind] as $actionName => $actionDesc) { if (isset($actionDesc['credentials'])) { $credentials = (array) $module->getSecurityManager()->parseCredentials($actionDesc['credentials']); foreach ($credentials as $credential) { $this->addPermissionFor($credential, $module->getKey(), $actionName); } } } } } } }
protected function getModuleManager() { if (null === $this->moduleManager) { $this->configuration->getConfigCache()->registerConfigHandler('config/dm/modules.yml', 'dmModuleManagerConfigHandler'); $mm = (include $this->configuration->getConfigCache()->checkConfig('config/dm/modules.yml')); dmModule::setManager($mm); dmDoctrineTable::setModuleManager($mm); dmDoctrineQuery::setModuleManager($mm); $this->moduleManager = $mm; } return $this->moduleManager; }
public function reloadModuleManager() { // create a new module_manager $this->factories['module_manager'] = (include $this->getConfigCache()->checkConfig('config/dm/modules.yml')); dmModule::setManager($this->factories['module_manager']); }
protected function getFilterAutoRecord(dmModule $filterModule) { return $this->getPage()->getRecord()->getAncestorRecord($filterModule->getModel()); }
protected function updateModuleShowPagesRecursive(dmModule $module) { $moduleKey = $module->getKey(); if (!$module->hasPage()) { foreach ($module->getChildren() as $child) { $this->updateModuleShowPagesRecursive($child); } return; } /* * prepares pages to update */ $_showPages = dmDb::pdo('SELECT p.id, p.module, p.record_id, p.lft, p.rgt FROM dm_page p WHERE p.module = ? AND p.action = ?', array($moduleKey, 'show'))->fetchAll(PDO::FETCH_ASSOC); $showPages = array(); foreach ($_showPages as $_showPage) { $showPages[$_showPage['record_id']] = $_showPage; } if ($module->hasListPage()) { $parentModule = $module; /* * prepare records */ // http://github.com/diem-project/diem/issues#issue/182 if (count($module->getTable()->getOption('inheritanceMap'))) { $records = $module->getTable()->createQuery('r')->select('r.id')->fetchArray(); } else { $records = dmDb::pdo('SELECT r.id FROM ' . $module->getTable()->getTableName() . ' r')->fetchAll(PDO::FETCH_ASSOC); } /* * prepare parent pages */ $parentPageIds = dmDb::pdo('SELECT p.id FROM dm_page p WHERE p.module = ? AND p.action = ?', array($moduleKey, 'list'))->fetch(PDO::FETCH_NUM); $parentPageIds = $parentPageIds[0]; if (!$parentPageIds) { throw new dmException(sprintf('%s needs a parent page, %s.%s, but it does not exists', $module, $moduleKey, 'list')); } $parentRecordIds = false; } else { if (!($parentModule = $module->getNearestAncestorWithPage())) { throw new dmException(sprintf('%s module is child of %s module, but %s module has no ancestor with page', $module, $parentModule, $module)); } /* * prepare records */ $select = 'r.id'; if ($module->hasLocal($module->getParent())) { $select .= ', r.' . $module->getTable()->getRelationHolder()->getLocalByClass($module->getParent()->getModel())->getLocal(); } // http://github.com/diem-project/diem/issues#issue/182 if (count($module->getTable()->getOption('inheritanceMap'))) { $records = $module->getTable()->createQuery('r')->select($select)->fetchArray(); } else { $records = dmDb::pdo('SELECT ' . $select . ' FROM ' . $module->getTable()->getTableName() . ' r')->fetchAll(PDO::FETCH_ASSOC); } /* * prepare parent pages */ $_parentPageIds = dmDb::pdo('SELECT p.id, p.record_id FROM dm_page p WHERE p.module = ? AND p.action = ?', array($parentModule->getKey(), 'show'))->fetchAll(PDO::FETCH_NUM); $parentPageIds = array(); foreach ($_parentPageIds as $value) { $parentPageIds[$value[1]] = $value[0]; } $parentRecordIds = $this->getParentRecordIds($module, $parentModule); } foreach ($records as $record) { if (isset($showPages[$record['id']])) { $page = $showPages[$record['id']]; } else { $page = array('id' => null, 'record_id' => $record['id'], 'module' => $moduleKey, 'action' => 'show'); } try { $this->updatePageFromRecord($page, $record, $module, $parentModule, $parentPageIds, $parentRecordIds); } catch (dmPageMustNotExistException $e) { if ($page['id']) { dmDb::table('DmPage')->find($page['id'])->getNode()->delete(); } } } foreach ($module->getChildren() as $child) { $this->updateModuleShowPagesRecursive($child); } }
public function __construct(dmModule $module, sfEventDispatcher $dispatcher) { $this->module = $module; $this->dispatcher = $dispatcher; $this->table = $module->getTable(); }
protected function getNbRecordsForModuleAndWeekDelta(dmModule $module, $weekDelta) { return $module->getTable()->createQuery('r')->where('r.created_at > ?', date('Y-m-d H:i:s', strtotime($weekDelta + 1 . ' week ago')))->andWhere('r.created_at <= ?', date('Y-m-d H:i:s', strtotime($weekDelta . ' week ago')))->count(); }
public static function setManager(dmModuleManager $manager) { self::$manager = $manager; }
protected function getSortReferersQuery(dmModule $refererModule) { return $refererModule->getTable()->createQuery('r')->whereIsActive(true, $refererModule->getModel())->orderBy('r.position asc'); }
public function getDefaultOptions() { return array_merge(parent::getDefaultOptions(), array('auto' => true)); }