本文整理汇总了PHP中ZurmoRedBean类的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoRedBean类的具体用法?PHP ZurmoRedBean怎么用?PHP ZurmoRedBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZurmoRedBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessStatusAndMessagesForEachRow
public function testProcessStatusAndMessagesForEachRow()
{
Yii::app()->user->userModel = User::getByUsername('super');
$import = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
$testTableName = $import->getTempTableName();
$this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName, true));
$count = ImportDatabaseUtil::getCount($testTableName);
$this->assertEquals(5, $count);
//Now add import results.
$resultsUtil = new ImportResultsUtil($import);
$rowDataResultsUtil = new ImportRowDataResultsUtil(2);
$rowDataResultsUtil->setStatusToUpdated();
$rowDataResultsUtil->addMessage('the first message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$rowDataResultsUtil = new ImportRowDataResultsUtil(3);
$rowDataResultsUtil->setStatusToCreated();
$rowDataResultsUtil->addMessage('the second message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$rowDataResultsUtil = new ImportRowDataResultsUtil(4);
$rowDataResultsUtil->setStatusToError();
$rowDataResultsUtil->addMessage('the third message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$resultsUtil->processStatusAndMessagesForEachRow();
$sql = 'select * from ' . $testTableName . ' where id != 1';
$tempTableData = ZurmoRedBean::getAll($sql);
$compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedMessages' => serialize(array('the first message')), 'analysisStatus' => null, 'serializedAnalysisMessages' => null), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedMessages' => serialize(array('the second message')), 'analysisStatus' => null, 'serializedAnalysisMessages' => null), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedMessages' => serialize(array('the third message')), 'analysisStatus' => null, 'serializedAnalysisMessages' => null), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedMessages' => null, 'analysisStatus' => null, 'serializedAnalysisMessages' => null));
$this->assertEquals($compareData, $tempTableData);
}
示例2: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
//Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$import = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true);
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
ZurmoRedBean::exec($sql);
$staleImportId = $import->id;
$import2 = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import2->serializedData = serialize($serializedData);
$this->assertTrue($import2->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName(), true);
$this->assertEquals(2, Import::getCount());
$tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
$this->assertTrue($tableExists);
$job = new ImportCleanupJob();
$this->assertTrue($job->run());
$tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
$this->assertFalse($tableExists);
$imports = Import::getAll();
$this->assertEquals(1, count($imports));
$this->assertEquals($import2->id, $imports[0]->id);
}
示例3: getByName
/**
* Given a name, get the custom field data model. Attempts to retrieve from cache, if it is not available,
* will attempt to retrieve from persistent storage, cache the model, and return.
* @param string $name
* @return CustomFieldData model
* @throws NotFoundException
*/
public static function getByName($name, $shouldCache = true)
{
if (isset(self::$cachedModelsByName[$name])) {
return self::$cachedModelsByName[$name];
}
try {
// not using default value to save cpu cycles on requests that follow the first exception.
return GeneralCache::getEntry('CustomFieldData' . $name);
} catch (NotFoundException $e) {
assert('is_string($name)');
assert('$name != ""');
$bean = ZurmoRedBean::findOne('customfielddata', "name = :name ", array(':name' => $name));
assert('$bean === false || $bean instanceof RedBean_OODBBean');
if ($bean === false) {
$customFieldData = new CustomFieldData();
$customFieldData->name = $name;
$customFieldData->serializedData = serialize(array());
// An unused custom field data does not present as needing saving.
$customFieldData->setNotModified();
} else {
$customFieldData = self::makeModel($bean);
}
if ($shouldCache) {
self::$cachedModelsByName[$name] = $customFieldData;
GeneralCache::cacheEntry('CustomFieldData' . $name, $customFieldData);
}
return $customFieldData;
}
}
示例4: getData
/**
* Runs a query to get all the dates for meetings based on SearchAttributeData. Then the data is processed
* and @returns a data array of dates and quantity. Quantity stands for how many meetings in a given date.
* (non-PHPdoc)
* @see CalendarDataProvider::getData()
*/
public function getData()
{
$sql = $this->makeSqlQuery();
$rows = ZurmoRedBean::getAll($sql);
$data = array();
foreach ($rows as $row) {
$localTimeZoneAdjustedDate = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($row['startdatetime'], 'medium', null);
if (isset($data[$localTimeZoneAdjustedDate])) {
$data[$localTimeZoneAdjustedDate]['quantity'] = $data[$localTimeZoneAdjustedDate]['quantity'] + 1;
} else {
$data[$localTimeZoneAdjustedDate] = array('date' => $localTimeZoneAdjustedDate, 'quantity' => 1, 'dbDate' => $row['startdatetime']);
}
}
foreach ($data as $key => $item) {
if ($item['quantity'] == 1) {
$label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModuleSingularLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
} else {
$label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModulePluralLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
}
$data[$key]['label'] = $label;
if ($item['quantity'] > 5) {
$quantityClassSuffix = 6;
} else {
$quantityClassSuffix = $item['quantity'];
}
$data[$key]['className'] = 'calendar-events-' . $quantityClassSuffix;
}
return $data;
}
示例5: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
//Create 2 sent notifications, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$emailMessage = EmailMessageTestHelper::createDraftSystemEmail('My Email Message', $super);
$emailMessage->folder = $folder;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $emailMessage->getClassId('Item');
ZurmoRedBean::exec($sql);
$emailMessage2 = EmailMessageTestHelper::createDraftSystemEmail('My Email Message 2', $super);
$emailMessage2->folder = $folder;
$saved = $emailMessage2->save();
$this->assertTrue($saved);
$this->assertEquals(2, EmailMessage::getCount());
$job = new ClearSentNotificationsEmailJob();
$this->assertTrue($job->run());
$emailMessages = EmailMessage::getAll();
$this->assertEquals(1, count($emailMessages));
$this->assertEquals($emailMessage2->id, $emailMessages[0]->id);
}
示例6: run
/**
* Deletes all job logs where the modifiedDateTime was more than 1 week ago.
* Runs operation in bulk to improve performance when large jobLogs are present.
*
* @see BaseJob::run()
*/
public function run()
{
$oneWeekAgoTimeStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 7);
$sql = 'DELETE from item, joblog using joblog inner join item on ' . 'item.id = joblog.item_id where joblog.enddatetime <= "' . $oneWeekAgoTimeStamp . '"';
ZurmoRedBean::exec($sql);
return true;
}
示例7: testSaveAllMetadata
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);
}
示例8: makeCombinedData
/**
* @return array
*/
protected function makeCombinedData()
{
$combinedRows = array();
//todo: should fix and get proper table name of attribute instead of passing in item
$groupBy = $this->resolveGroupBy('EmailMessage', 'sentDateTime');
$beginDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($this->beginDate);
$endDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($this->endDate);
if ($this->marketingList == null) {
$searchAttributeData = static::makeCampaignsSearchAttributeData('createdDateTime', $beginDateTime, $endDateTime, $this->campaign);
$sql = static::makeCampaignsSqlQuery($searchAttributeData, $groupBy);
$rows = ZurmoRedBean::getAll($sql);
foreach ($rows as $row) {
$this->addNewRowToCombinedRows($row, $combinedRows);
}
}
if ($this->campaign == null) {
$searchAttributeData = static::makeAutorespondersSearchAttributeData('createdDateTime', $beginDateTime, $endDateTime, $this->marketingList);
$sql = static::makeAutorespondersSqlQuery($searchAttributeData, $groupBy);
$rows = ZurmoRedBean::getAll($sql);
foreach ($rows as $row) {
$this->addNewRowToCombinedRows($row, $combinedRows);
}
}
return $combinedRows;
}
示例9: testRun
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']);
}
示例10: testProperlyDeletingActivityItems
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');
}
示例11: updateByModel
/**
* Given a model and external system id, update the external system id in the database for that model
* @param object $model
* @param string $externalSystemId
*/
public static function updateByModel(RedBeanModel $model, $externalSystemId)
{
assert('$externalSystemId == null || is_string($externalSystemId)');
$columnName = self::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
$tableName = $model::getTableName();
static::addExternalIdColumnIfMissing($tableName);
ZurmoRedBean::exec("update " . $tableName . " set {$columnName} = '" . $externalSystemId . "' where id = " . $model->id);
}
示例12: getUserExternalSystemIds
public static function getUserExternalSystemIds()
{
$columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
$userTableName = User::getTableName();
ExternalSystemIdUtil::addExternalIdColumnIfMissing($userTableName);
$sql = 'select ' . $columnName . ' from ' . $userTableName;
return ZurmoRedBean::getCol($sql);
}
示例13: deleteConversationItems
/**
* Given a event, perform the deletion of conversationItems related to the event sender.
* @param CEvent $event
*/
public function deleteConversationItems(CEvent $event)
{
$model = $event->sender;
assert('$model instanceof Item');
$itemId = $model->getClassId('Item');
$sql = 'DELETE from conversation_item where item_id = ' . $itemId;
ZurmoRedBean::exec($sql);
}
示例14: cacheEntry
public static function cacheEntry($identifier, $entry)
{
assert('is_string($entry) || is_numeric($entry)');
parent::cacheEntry($identifier, $entry);
if (static::supportsAndAllowsDatabaseCaching()) {
ZurmoRedBean::exec("insert into actual_rights_cache\n (identifier, entry) values ('" . $identifier . "', '" . $entry . "') on duplicate key\n update entry = " . $entry);
}
}
示例15: calculateTotalItemCount
/**
* @return int
*/
public function calculateTotalItemCount()
{
$selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
$sql = $this->makeSqlQueryForFetchingTotalItemCount($selectQueryAdapter);
$rows = ZurmoRedBean::getAll($sql);
$count = count($rows);
return $count;
}