Ejemplo n.º 1
0
 public function testCreateStarredTables()
 {
     StarredUtil::createStarredTables();
     $sql = "SHOW TABLES LIKE '%_starred'";
     $allStarredTableRows = R::getAll($sql);
     $this->assertCount(4, $allStarredTableRows);
 }
 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 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));
     }
 }
Ejemplo n.º 4
0
 /**
  * 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();
 }
Ejemplo n.º 5
0
 /**
  * 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());
     }
 }