public function testProperlyDeletingActivityItems() { Yii::app()->user->userModel = User::getByUsername('super'); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(0, $count['count']); $account = AccountTestHelper::createAccountByNameForOwner('anAccount', Yii::app()->user->userModel); $deleted = $account->delete(); $this->assertTrue($deleted); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(0, $count['count']); $account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('anOpp', Yii::app()->user->userModel); $task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('aTask', Yii::app()->user->userModel, $account2); $task->activityItems->add($opportunity); $this->assertTrue($task->save()); $taskId = $task->id; $task->forget(); RedBeansCache::forgetAll(); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(2, $count['count']); $deleted = $account2->delete(); $this->assertTrue($deleted); $account2->forget(); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(1, $count['count']); RedBeansCache::forgetAll(); //Make sure things render ok even with the account deleted. $content = ActivitiesUtil::renderSummaryContent(Task::getById($taskId), 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule'); }
public function testSaveAllMetadata() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $this->assertTrue(ContactsModule::loadStartingData()); $messageLogger = new MessageLogger(); InstallUtil::autoBuildDatabase($messageLogger, true); chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands'); $command = "php zurmocTest.php manageMetadata super saveAllMetadata"; if (!IS_WINNT) { $command .= ' 2>&1'; } exec($command, $output); // Check if data are saved for some specific View $moduleMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='NotesModule'"); $this->assertTrue($moduleMetadata['id'] > 0); $this->assertTrue(strlen($moduleMetadata['serializedmetadata']) > 0); // Check if data are saved for some specific View $modelMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='Note'"); $this->assertTrue($modelMetadata['id'] > 0); $this->assertTrue(strlen($modelMetadata['serializedmetadata']) > 0); // Check if data are saved for some specific View $viewMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='ContactsListView'"); $this->assertTrue($viewMetadata['id'] > 0); $this->assertTrue(strlen($viewMetadata['serializedmetadata']) > 0); }
public function testRun() { //Create 2 jobLogs, and set one with a date over a week ago (8 days ago) for the endDateTime $eightDaysAgoTimestamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8); $jobLog = new JobLog(); $jobLog->type = 'Monitor'; $jobLog->startDateTime = $eightDaysAgoTimestamp; $jobLog->endDateTime = $eightDaysAgoTimestamp; $jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR; $jobLog->isProcessed = false; $jobLog->save(); $jobLog2 = new JobLog(); $jobLog2->type = 'ImportCleanup'; $jobLog2->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $jobLog2->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $jobLog2->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR; $jobLog2->isProcessed = false; $jobLog2->save(); $sql = 'select count(*) count from item'; $row = ZurmoRedBean::getRow($sql); $this->assertEquals(4, $row['count']); $job = new JobLogCleanupJob(); $this->assertTrue($job->run()); $jobLogs = JobLog::getAll(); $this->assertEquals(1, count($jobLogs)); $this->assertEquals($jobLog2->id, $jobLogs[0]->id); $sql = 'select count(*) count from item'; $row = ZurmoRedBean::getRow($sql); $this->assertEquals(3, $row['count']); }
public function getChartData() { $sql = static::makeSqlQuery(static::makeSearchAttributeData($this->autoresponder)); $row = ZurmoRedBean::getRow($sql); $data = static::resolveChartDataBaseGroupElements(); foreach ($data as $index => $notUsed) { if ($row[$index] != null) { $data[$index] = $row[$index]; } } return $data; }
public function testRecreateTable() { ReadPermissionsSubscriptionUtil::recreateTable('account_read_subscription'); $sql = 'INSERT INTO account_read_subscription VALUES (null, \'1\', \'2\', \'2013-05-03 15:16:06\', \'1\')'; ZurmoRedBean::exec($sql); $accountReadSubscription = ZurmoRedBean::getRow("SELECT * FROM account_read_subscription"); $this->assertTrue($accountReadSubscription['id'] > 0); $this->assertEquals(1, $accountReadSubscription['userid']); $this->assertEquals(2, $accountReadSubscription['modelid']); $this->assertEquals('2013-05-03 15:16:06', $accountReadSubscription['modifieddatetime']); $this->assertEquals(1, $accountReadSubscription['subscriptiontype']); $sql = 'DELETE FROM account_read_subscription'; ZurmoRedBean::exec($sql); }
/** * @return array */ public function getChartData() { $chartData = array(); $groupedDateTimeData = static::makeGroupedDateTimeData($this->beginDate, $this->endDate, $this->groupBy, false); foreach ($groupedDateTimeData as $groupData) { $beginDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($groupData['beginDate']); $endDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($groupData['endDate']); $searchAttributedata = static::makeSearchAttributeData($endDateTime, $this->marketingList); $sql = static::makeColumnSqlQuery($beginDateTime, $searchAttributedata); $row = ZurmoRedBean::getRow($sql); $columnData = array(MarketingChartDataProvider::NEW_SUBSCRIBERS_COUNT => ArrayUtil::getArrayValueAndResolveNullAsZero($row, static::NEW_SUBSCRIBERS_COUNT), MarketingChartDataProvider::EXISTING_SUBSCRIBERS_COUNT => ArrayUtil::getArrayValueAndResolveNullAsZero($row, static::EXISTING_SUBSCRIBERS_COUNT), 'displayLabel' => $groupData['displayLabel'], 'dateBalloonLabel' => $this->resolveDateBalloonLabel($groupData['displayLabel'])); $chartData[] = $columnData; } return $chartData; }
public function testRebuilt() { ModelCreationApiSyncUtil::buildTable(); $sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'1\', \'Contact\', \'2013-05-03 15:16:06\')'; ZurmoRedBean::exec($sql); $apiServiceCreationRow = ZurmoRedBean::getRow('SELECT * FROM ' . ModelCreationApiSyncUtil::TABLE_NAME); $this->assertTrue($apiServiceCreationRow['id'] > 0); $this->assertEquals('ApiServiceName', $apiServiceCreationRow['servicename']); $this->assertEquals(1, $apiServiceCreationRow['modelid']); $this->assertEquals('Contact', $apiServiceCreationRow['modelclassname']); $this->assertEquals('2013-05-03 15:16:06', $apiServiceCreationRow['createddatetime']); // Now test when table already exist ModelCreationApiSyncUtil::buildTable(); $apiServiceCreationRow = ZurmoRedBean::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME); $this->assertEquals(1, $apiServiceCreationRow['totalRows']); $sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'2\', \'Contact\', \'2013-06-03 15:16:06\')'; ZurmoRedBean::exec($sql); $apiServiceCreationRow = ZurmoRedBean::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME); $this->assertEquals(2, $apiServiceCreationRow['totalRows']); }
public function testDeletingSenderAndRecipientsPersonsOrAccountsItems() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $emailMessage = EmailMessageTestHelper::createDraftSystemEmail('test crud relations', $super); $contact = ContactTestHelper::createContactByNameForOwner('samson', $super); $count = ZurmoRedBean::getRow('select count(*) count from emailmessagerecipient_item'); $this->assertEquals(0, $count['count']); $count = ZurmoRedBean::getRow('select count(*) count from emailmessagesender_item'); $this->assertEquals(0, $count['count']); //Add contact as sender personOrAccounts $emailMessageSender = new EmailMessageSender(); $emailMessageSender->fromAddress = '*****@*****.**'; $emailMessageSender->fromName = 'system name'; $emailMessageSender->personsOrAccounts->add($contact); $emailMessage->sender = $emailMessageSender; //Add also as recipient personOrAccounts $recipient = new EmailMessageRecipient(); $recipient->toAddress = '*****@*****.**'; $recipient->toName = 'Sam Sammy'; $recipient->type = EmailMessageRecipient::TYPE_TO; $recipient->personsOrAccounts->add($contact); $emailMessage->recipients->add($recipient); //Save emailMessage $saved = $emailMessage->save(); $this->assertTrue($saved); $count = ZurmoRedBean::getRow('select count(*) count from emailmessagerecipient_item'); $this->assertEquals(1, $count['count']); $count = ZurmoRedBean::getRow('select count(*) count from emailmessagesender_item'); $this->assertEquals(1, $count['count']); $emailMessage->forget(); //Now delete the contact and try to retrieve the email message $deleted = $contact->delete(); $this->assertTrue($deleted); //Now make sure the intermediate join table rows are removed $count = ZurmoRedBean::getRow('select count(*) count from emailmessagerecipient_item'); $this->assertEquals(0, $count['count']); $count = ZurmoRedBean::getRow('select count(*) count from emailmessagesender_item'); $this->assertEquals(0, $count['count']); }
public static function getEntry($identifier, $default = 'NOT_FOUND_EXCEPTION', $cacheDefaultValue = false) { try { return parent::getEntry($identifier, $default, $cacheDefaultValue); } catch (NotFoundException $e) { if (static::supportsAndAllowsDatabaseCaching()) { $row = ZurmoRedBean::getRow("select entry from actual_rights_cache " . "where identifier = '" . $identifier . "'"); if ($row != null && isset($row['entry'])) { //Calling parent because we don't need to re-cache the db cache item parent::cacheEntry($identifier, $row['entry']); return $row['entry']; } } if ($default === 'NOT_FOUND_EXCEPTION') { throw new NotFoundException(); } else { if ($cacheDefaultValue) { static::cacheEntry($identifier, $default); } return $default; } } }
protected function resolveMakeTemplateFunctionDefinitionById($id, &$functionDefinitions, array &$functionNames) { $name = null; $builttype = null; $serializeddata = null; $emailTemplate = ZurmoRedBean::getRow('select name, builttype, serializeddata from emailtemplate where id =' . $id); if (empty($emailTemplate)) { throw new NotFoundException("Unable to load model for id: {$id}"); } extract($emailTemplate); if ($builttype != EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE) { throw new NotSupportedException("id: {$id} is not a builder template"); } $unserializedData = CJSON::decode($serializeddata); if (json_last_error() != JSON_ERROR_NONE || empty($unserializedData)) { throw new NotSupportedException("JSON could not be translated"); } $unserializedData['baseTemplateId'] = ''; $unserializedData['icon'] = ArrayUtil::getArrayValue($this->templateNameToIconMapping, $name); $unserializedData = var_export($unserializedData, true); $functionName = $this->resolveFunctionNameFromTemplateName($name); $functionNames[] = $functionName; $functionDefinitions .= "\n\nprotected function {$functionName}()\n{\n \$name = '{$name}';\n \$unserializedData = {$unserializedData};\n \$this->makeBuilderPredefinedEmailTemplate(\$name, \$unserializedData);\n}"; }
public function testRun() { chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands'); $command = "php zurmocTest.php install {$this->temporaryDatabaseHostname} {$this->temporaryDatabaseName} "; $command .= "{$this->temporaryDatabaseUsername} {$this->temporaryDatabasePassword} {$this->temporaryDatabasePort} "; $command .= "{$this->superUserPassword} 'http://sampleHost' 'app/index.php' demodata 1"; if (!IS_WINNT) { $command .= ' 2>&1'; } exec($command, $output); $instanceRoot = INSTANCE_ROOT; $perInstanceConfigFile = "{$instanceRoot}/protected/config/perInstanceTest.php"; $debugConfigFile = "{$instanceRoot}/protected/config/debugTest.php"; $perInstanceConfiguration = file_get_contents($perInstanceConfigFile); $debugConfiguration = file_get_contents($debugConfigFile); //Check if config files is updated. $this->assertRegExp('/\\$connectionString = \'mysql:host=' . $this->temporaryDatabaseHostname . ';port=' . $this->temporaryDatabasePort . ';dbname=' . $this->temporaryDatabaseName . '\';/', $perInstanceConfiguration); $this->assertRegExp('/\\$username = \'' . $this->temporaryDatabaseUsername . '\';/', $perInstanceConfiguration); $this->assertRegExp('/\\$password = \'' . $this->temporaryDatabasePassword . '\';/', $perInstanceConfiguration); RedBeanDatabase::close(); RedBeanDatabase::setup(Yii::app()->tempDb->connectionString, Yii::app()->tempDb->username, Yii::app()->tempDb->password, true); $count = ZurmoRedBean::getRow('select count(*) count from _user'); if (Yii::app()->edition == 'Community') { $this->assertEquals(10, $count['count']); } else { $this->assertEquals(14, $count['count']); } }
/** * Get by campaign or autoresponder item. * @param OwnedModel $item * @return int */ public static function getIdByCampaignOrAutoresponderItem($item) { $itemClassName = get_class($item); $type = strtolower($itemClassName); $modelClassName = $itemClassName . 'Activity'; $tableName = $modelClassName::getTableName(); $rows = ZurmoRedBean::getRow('select emailmessageactivity_id from ' . $tableName . ' where ' . $type . '_id = ?', array($item->id)); if (!empty($rows)) { return $rows['emailmessageactivity_id']; } return null; }
public function testMultipleManyManysToTheSameModel() { $pp1 = new PP(); $pp1->name = 'pp1a'; $pp1->save(); $this->assertTrue($pp1->save()); $pp1Id = $pp1->id; $pp2 = new PP(); $pp2->name = 'pp2a'; $this->assertTrue($pp2->save()); $pp2Id = $pp2->id; $p = new P(); $p->name = 'manyNames'; $p->ppManyAssumptive->add($pp1); $p->ppManySpecific->add($pp2); $this->assertTrue($p->save()); $pId = $p->id; //Retrieve row to make sure columns are coppect $row = ZurmoRedBean::getRow('select * from p'); $this->assertCount(5, $row); $this->assertEquals(1, ZurmoRedBean::count('p_pp')); $row = ZurmoRedBean::getRow('select * from p_pp'); $this->assertTrue(isset($row['p_id']) && ($row['p_id'] = $p->id)); $this->assertTrue(isset($row['pp_id']) && ($row['pp_id'] = $pp1->id)); $this->assertCount(3, $row); $this->assertEquals(1, ZurmoRedBean::count('ppmanyspecificlink_p_pp')); $row = ZurmoRedBean::getRow('select * from ppmanyspecificlink_p_pp'); $this->assertTrue(isset($row['p_id']) && ($row['p_id'] = $p->id)); $this->assertTrue(isset($row['pp_id']) && ($row['pp_id'] = $pp2->id)); $this->assertCount(3, $row); //Unlink and make sure the tables are cleared $p->forget(); $pp1->forget(); $pp2->forget(); $p = P::getById($pId); $this->assertEquals(1, $p->ppManyAssumptive->count()); $this->assertEquals(1, $p->ppManySpecific->count()); $p->ppManyAssumptive->removeAll(); $p->ppManySpecific->removeAll(); $this->assertTrue($p->save()); $this->assertEquals(0, ZurmoRedBean::count('p_pp')); $this->assertEquals(0, ZurmoRedBean::count('ppmanyspecificlink_p_pp')); }
/** * Get database max alowed packet size. * @throws NotSupportedException */ public static function getDatabaseMaxAllowedPacketsSizeRb() { if (RedBeanDatabase::getDatabaseType() != 'mysql') { throw new NotSupportedException(); } $row = ZurmoRedBean::getRow("SHOW VARIABLES LIKE 'max_allowed_packet'"); if (isset($row['Value'])) { return $row['Value']; } else { return null; } }
public function testPolyOneToManyNotOwned() { $polySide = new TestPolyOneToManyPolySide(); $polySide->name = 'polySideTest'; $oneSide = new TestPolyOneToManyOneSide(); $oneSide->name = 'oneSideTest'; $oneSide->polys->add($polySide); $this->assertTrue($oneSide->save()); $polySideId = $polySide->id; $this->assertTrue($polySideId > 0); $oneSideId = $oneSide->id; $oneSide->forget(); unset($oneSide); $polySide2 = new TestPolyOneToManyPolySide(); $polySide2->name = 'polySideTest2'; $oneSide2 = new TestPolyOneToManyOneSideTwo(); $oneSide2->name = 'oneSideTwoTest'; $oneSide2->polysTwo->add($polySide2); $this->assertTrue($oneSide2->save()); $polySide2Id = $polySide2->id; $this->assertTrue($polySide2Id > 0); $oneSide2Id = $oneSide2->id; $oneSide2->forget(); unset($oneSide2); //Get oneSide and make sure it has one polySide that matches the appropriate id $oneSide = TestPolyOneToManyOneSide::getById($oneSideId); $this->assertEquals(1, $oneSide->polys->count()); $this->assertEquals($polySideId, $oneSide->polys[0]->id); //Get oneSide2 and make sure it has one polySide2 that matches the appropriate id $oneSide2 = TestPolyOneToManyOneSideTwo::getById($oneSide2Id); $this->assertEquals(1, $oneSide2->polysTwo->count()); $this->assertEquals($polySide2Id, $oneSide2->polysTwo[0]->id); //do a direct sql to get the row for polySide $row = ZurmoRedBean::getRow('select * from testpolyonetomanypolyside'); $this->assertTrue(!isset($row['testpolyonetomanyoneside_id'])); $this->assertTrue(!isset($row['testpolyonetomanyonesidetwo_id'])); //Confirm the poly type and poly id columns are there. $this->assertTrue(isset($row['polytest_type'])); $this->assertTrue(isset($row['polytest_id'])); //test adding an extra PolySide to oneSide $polySide3 = new TestPolyOneToManyPolySide(); $polySide3->name = 'polySideTest3'; $oneSide->polys->add($polySide3); $this->assertTrue($oneSide->save()); $polySide3Id = $polySide3->id; $oneSide->forget(); unset($oneSide); //Now test there are 2 related polys $oneSide = TestPolyOneToManyOneSide::getById($oneSideId); $this->assertEquals(2, $oneSide->polys->count()); $this->assertEquals($polySideId, $oneSide->polys[0]->id); $this->assertEquals($polySide3Id, $oneSide->polys[1]->id); //test disconnect a polySide, it should also remove the attached model from db. TestPolyOneToManyPolySide should be three $polySide = $oneSide->polys[0]; $oneSide->polys->remove($polySide); $this->assertTrue($oneSide->save()); $this->assertEquals(2, TestPolyOneToManyPolySide::getCount()); //Now test there is 1 related polys $oneSide = TestPolyOneToManyOneSide::getById($oneSideId); $this->assertEquals(1, $oneSide->polys->count()); $this->assertEquals($polySide3Id, $oneSide->polys[0]->id); $this->assertEquals(2, TestPolyOneToManyPolySide::getCount()); $this->assertTrue($oneSide->delete()); $this->assertEquals(1, TestPolyOneToManyPolySide::getCount()); TestPolyOneToManyPolySide::deleteAll(); $this->assertEquals(0, TestPolyOneToManyPolySide::getCount()); }
/** * Given the name of a named securable item, return the cached entry if available. * @param $namedSecurableItemName * @param $permitable * @return mixed * @throws NotFoundException */ public static function getNamedSecurableItemActualPermissions($namedSecurableItemName, $permitable) { assert('is_string($namedSecurableItemName)'); assert('$permitable instanceof Permitable'); $cacheKeyName = $namedSecurableItemName . get_class($permitable) . $permitable->id . 'ActualPermissions'; if (static::supportsAndAllowsPhpCaching()) { if (isset(static::$namedSecurableItemActualPermissions[$cacheKeyName])) { return static::$namedSecurableItemActualPermissions[$cacheKeyName]; } } if (static::supportsAndAllowsMemcache()) { $prefix = static::getCachePrefix($cacheKeyName); $serializedData = Yii::app()->cache->get($prefix . $cacheKeyName); if ($serializedData !== false) { $actualPermissions = unserialize($serializedData); assert('is_array($actualPermissions)'); return $actualPermissions; } } if (static::supportsAndAllowsDatabaseCaching()) { if ($permitable->getClassId('Permitable') > 0) { $row = ZurmoRedBean::getRow("select allow_permissions, deny_permissions " . "from named_securable_actual_permissions_cache " . "where securableitem_name = '" . $namedSecurableItemName . "' and " . "permitable_id = '" . $permitable->getClassId('Permitable') . "'"); if ($row != null && isset($row['allow_permissions']) && isset($row['deny_permissions'])) { static::cacheNamedSecurableItemActualPermissions($namedSecurableItemName, $permitable, array($row['allow_permissions'], $row['deny_permissions']), false); return array($row['allow_permissions'], $row['deny_permissions']); } } } throw new NotFoundException(); }
/** * @param User $user * @param string $levelType * @return array */ public static function getSummationPointsDataByLevelTypeAndUser(User $user, $levelType) { assert('$user->id > 0'); assert('is_string($levelType) && $levelType != null'); $wherePart = static::getPointTypeWherePartByLevelType($levelType); $sql = "select sum(value) sum from gamepoint where " . $wherePart . " person_item_id = " . $user->getClassId('Item') . " group by person_item_id"; return ZurmoRedBean::getRow($sql); }
/** * @depends testGetUnreadConversationCount */ public function testDeleteConversation() { $conversations = Conversation::getAll(); $this->assertEquals(3, count($conversations)); $comments = Comment::getAll(); $this->assertEquals(4, count($comments)); //check count of conversation_items $count = ZurmoRedBean::getRow('select count(*) count from conversation_item'); $this->assertEquals(2, $count['count']); //remove the account, tests tthat ConversationObserver is correctly removing data from conversation_item $accounts = Account::getByName('anAccount2'); $this->assertTrue($accounts[0]->delete()); $count = ZurmoRedBean::getRow('select count(*) count from conversation_item'); $this->assertEquals(1, $count['count']); foreach ($conversations as $conversation) { $conversationId = $conversation->id; $conversation->forget(); $conversation = Conversation::getById($conversationId); $deleted = $conversation->delete(); $this->assertTrue($deleted); } //Count of conversation items should be 0 since the ConversationsObserver should make sure it gets removed correctly. $count = ZurmoRedBean::getRow('select count(*) count from conversation_item'); $this->assertEquals(0, $count['count']); //check that all comments are removed, since they are owned. $comments = Comment::getAll(); $this->assertEquals(0, count($comments)); }
/** * Check if the portlet is already added to the detail view. This would * take care of the case where user click on the link in select portlet * list more than one time * @param string $viewType * @param string $uniqueLayoutId * @param int $userId * @return boolean */ public static function doesPortletExistByViewTypeLayoutIdAndUser($viewType, $uniqueLayoutId, $userId) { assert('is_integer($userId) && $userId >= 1'); $sql = "select count(*) as count " . 'from portlet ' . "where layoutid = '" . DatabaseCompatibilityUtil::escape($uniqueLayoutId) . "' and viewtype = '" . DatabaseCompatibilityUtil::escape($viewType) . "' and _user_id = " . DatabaseCompatibilityUtil::escape($userId); $row = ZurmoRedBean::getRow($sql); if ($row['count'] > 0) { return true; } else { return false; } }