protected function renderTitleContent() { $starLink = StarredUtil::getToggleStarStatusLink($this->model, null); $content = StringUtil::renderFluidContent($this->getTitle()); $content .= $starLink; return ZurmoHtml::tag('h1', array(), $content); }
protected function resolveNameContent() { $starLink = null; $spanContent = null; if (StarredUtil::modelHasStarredInterface($this->model)) { $starLink = StarredUtil::getToggleStarStatusLink($this->model, null); } return ZurmoHtml::tag('h2', array(), $spanContent . strval($this->model) . $starLink . $this->renderGoToDetailsLink()); }
protected function resolveExtraSql(RedBeanModelJoinTablesQueryAdapter &$joinTablesAdapter, &$where) { if ($where != '') { $where .= ' and '; } $user = Yii::app()->user->userModel; $quote = DatabaseCompatibilityUtil::getQuote(); $starredTableName = StarredUtil::getStarredTableName($this->modelClassName); $extraOnQueryPart = "and {$quote}{$starredTableName}{$quote}.{$quote}user_id{$quote} = {$user->id}"; $starredTableAliasName = $joinTablesAdapter->addLeftTableAndGetAliasName($starredTableName, 'id', null, 'model_id', $extraOnQueryPart); $where .= "{$quote}{$starredTableAliasName}{$quote}.{$quote}user_id{$quote} = {$user->id}"; }
protected function resolveNameContent() { $element = new DropDownElement($this->model, 'title', null); $element->nonEditableTemplate = '{content}'; $starLink = null; $spanContent = null; if (StarredUtil::modelHasStarredInterface($this->model)) { $starLink = StarredUtil::getToggleStarStatusLink($this->model, null); } $salutation = $element->render(); if ($salutation != null) { $spanContent = ZurmoHtml::tag('span', array('class' => 'salutation'), $element->render()); } return ZurmoHtml::tag('h2', array(), $spanContent . strval($this->model) . $starLink . $this->renderGoToDetailsLink()); }
protected function resolveExtraSql(RedBeanModelJoinTablesQueryAdapter &$joinTablesAdapter, &$where) { $user = Yii::app()->user->userModel; $quote = DatabaseCompatibilityUtil::getQuote(); if ($where != '') { $where .= ' and '; } $modelClassName = $this->modelClassName; $starredClassName = StarredUtil::getStarredModelClassName($modelClassName); $starredTableName = $starredClassName::getTableName(); $modelIdColumnName = $modelClassName::getTableName() . '_id'; $baseStarredTableName = BaseStarredModel::getTableName(); $baseStarredColumnName = $baseStarredTableName . '_id'; $starredTableAliasName = $joinTablesAdapter->addLeftTableAndGetAliasName($starredTableName, 'id', null, $modelIdColumnName); $baseStarredTableAliasName = $joinTablesAdapter->addFromTableAndGetAliasName($baseStarredTableName, $baseStarredColumnName, $starredTableAliasName); $where .= "{$quote}{$baseStarredTableAliasName}{$quote}.{$quote}_user_id{$quote} = {$user->id}"; }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); ZurmoDatabaseCompatibilityUtil::createActualPermissionsCacheTable(); ZurmoDatabaseCompatibilityUtil::dropStoredFunctionsAndProcedures(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; StarredUtil::createStarredTables(); $account = new Account(); $account->owner = $super; $account->name = 'Test Account0'; $account->officePhone = '1234567890'; $account->save(); StarredUtil::markModelAsStarred($account); $account = new Account(); $account->owner = $super; $account->name = 'Test Account1'; $account->officePhone = '1234567891'; $account->save(); }
public function testGetToggleStarStatusLink() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $account = new Account(); $account->owner = $super; $account->name = 'Test Account'; $account->officePhone = '1234567890'; $this->assertTrue($account->save()); $dataProvider = new RedBeanModelDataProvider('Account'); $data = $dataProvider->getData(); $link = StarredUtil::getToggleStarStatusLink($data[0], null); $this->assertContains('unstarred', $link); $this->assertContains('star-Account-' . $account->id, $link); }
public function testToggleStar() { if (!RedBeanDatabase::isFrozen()) { StarredUtil::createStarredTables(); $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $account = new Account(); $account->owner = $super; $account->name = 'Test Account'; $account->officePhone = '1234567890'; $this->assertTrue($account->save()); $this->setGetArray(array('modelClassName' => 'Account', 'modelId' => $account->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/toggleStar'); $this->assertEquals('icon-star starred', $content); $this->assertTrue(StarredUtil::isModelStarred($account)); $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/toggleStar'); $this->assertEquals('icon-star unstarred', $content); $this->assertFalse(StarredUtil::isModelStarred($account)); } }
public function getPostTruncatedTitleContent() { return StarredUtil::getToggleStarStatusLink($this->savedReport, null); }
/** * Override to add a starring link to the title * @return string */ public function getTitle() { $starLink = StarredUtil::getToggleStarStatusLink($this->model, null); return parent::getTitle() . $starLink; }
/** * Render a hidden field to filter models by starred only * @param ZurmoActiveForm $form * @return string */ protected function renderStarredFilterHidenField($form) { $content = null; if (StarredUtil::modelHasStarredInterface($this->model->getModel())) { $content .= $form->hiddenField($this->model, 'filterByStarred', array('class' => $form->id . '_filterByStarred')); } return $content; }
/** * Auto builds the database. Must manually set AuditEvent first to avoid issues building the AuditEvent * table. This is because AuditEvent is specially optimized during this build process to reduce how * long this takes to do. */ public static function autoBuildDatabase(&$messageLogger) { $rootModels = array(); $rootModels[] = 'AuditEvent'; foreach (Module::getModuleObjects() as $module) { $moduleAndDependenciesRootModelNames = $module->getRootModelNamesIncludingDependencies(); $rootModels = array_merge($rootModels, array_diff($moduleAndDependenciesRootModelNames, $rootModels)); } ZurmoDatabaseCompatibilityUtil::createStoredFunctionsAndProcedures(); RedBeanDatabaseBuilderUtil::autoBuildModels($rootModels, $messageLogger); ZurmoDatabaseCompatibilityUtil::createIndexes(); StarredUtil::createStarredTables(); ReadPermissionsSubscriptionUtil::buildTables(); }
public function actionToggleStar($modelClassName, $modelId) { echo StarredUtil::toggleModelStarStatus($modelClassName, (int) $modelId); }
/** * Execute the action. * @param array command line parameters specific for this command */ public function run($args) { set_time_limit('900'); if (!isset($args[0])) { $this->usageError('A username must be specified.'); } try { Yii::app()->user->userModel = User::getByUsername($args[0]); } catch (NotFoundException $e) { $this->usageError('The specified username does not exist.'); } $group = Group::getByName(Group::SUPER_ADMINISTRATORS_GROUP_NAME); if (!$group->users->contains(Yii::app()->user->userModel)) { $this->usageError('The specified user is not a super administrator.'); } $startTime = microtime(true); $template = "{message}\n"; $messageStreamer = new MessageStreamer($template); $messageStreamer->setExtraRenderBytes(0); $messageStreamer->add(Zurmo::t('Commands', 'Starting schema update process.')); $messageLogger = new MessageLogger($messageStreamer); InstallUtil::runAutoBuildFromUpdateSchemaCommand($messageLogger); $messageStreamer->add(Zurmo::t('Commands', 'Autobuild complete, rebuilding read permissions.')); if (SHOW_QUERY_DATA) { $messageStreamer->add(PageView::getTotalAndDuplicateQueryCountContent()); } ReadPermissionsOptimizationUtil::rebuild(); $messageStreamer->add(Zurmo::t('Commands', 'Rebuild read permissions complete.')); StarredUtil::createStarredTables(); $messageStreamer->add(Zurmo::t('Commands', 'Tables creating for starred models completed.')); $endTime = microtime(true); $messageStreamer->add(Zurmo::t('Commands', 'Schema update complete.')); $messageStreamer->add(Zurmo::t('Commands', 'Total run time: {formattedTime} seconds.', array('{formattedTime}' => number_format($endTime - $startTime, 3)))); if (SHOW_QUERY_DATA) { $messageStreamer->add(PageView::getTotalAndDuplicateQueryCountContent()); } }
/** * Render a checkBox to filter models by starred only * @param ZurmoActiveForm $form * @return string */ protected function renderStarredFilterHidenField($model, $form) { $content = null; $modelsImplementsStarredInterface = false; if (isset($this->modelClassName) && StarredUtil::modelHasStarredInterface($this->modelClassName)) { $modelsImplementsStarredInterface = true; } if ($modelsImplementsStarredInterface) { $content .= $form->hiddenField($model, 'filterByStarred', array('class' => $form->id . '_filterByStarred')); } return $content; }