public function testTimeSinceUpdate()
 {
     // 10 Minutes 1206028575/1206028586
     $dataBaseTime = "2008-03-20 11:56:15";
     //1206028598
     $test10sec = 1206028585;
     $test10min = 1206029198;
     $test10hours = 1206064198;
     $test10days = 1206892572;
     //Seconds
     $arryUpdateTime = ProfileApp::timeSinceUpdate($dataBaseTime, $test10sec);
     $this->assertEquals(2, sizeof($arryUpdateTime));
     $this->assertEquals('seconds', $arryUpdateTime['units']);
     $this->assertEquals(10, $arryUpdateTime['value']);
     //Minutes
     $arryUpdateTime = ProfileApp::timeSinceUpdate($dataBaseTime, $test10min);
     $this->assertEquals(2, sizeof($arryUpdateTime));
     $this->assertEquals('minutes', $arryUpdateTime['units']);
     $this->assertEquals(10, $arryUpdateTime['value']);
     //Hours
     $arryUpdateTime = ProfileApp::timeSinceUpdate($dataBaseTime, $test10hours);
     $this->assertEquals(2, sizeof($arryUpdateTime));
     $this->assertEquals('hours', $arryUpdateTime['units']);
     $this->assertEquals(10, $arryUpdateTime['value']);
     //Days
     $arryUpdateTime = ProfileApp::timeSinceUpdate($dataBaseTime, $test10days);
     $this->assertEquals(2, sizeof($arryUpdateTime));
     $this->assertEquals('days', $arryUpdateTime['units']);
     $this->assertEquals(10, $arryUpdateTime['value']);
 }
Beispiel #2
0
 /**
  * Renders the users current status and a form which can be used to update
  * your status.
  */
 public function getStatusBlock($flavor = 'wide')
 {
     $statusRow = new Status();
     $statusRow = $statusRow->find($this->uid);
     $status_fbml[] = "<div id='profile_status' class='profile_status'><div id='status_caption{$flavor}'>\n";
     if (is_null($statusRow)) {
         $status_text = "Status Unknown";
         $status_fbml[] = "{$status_text}<br>\n";
         //$status_fbml[]="And has never been updated.<br>\n";
     } else {
         if (strtoupper(substr($statusRow->status, 0, 2)) == 'IS') {
             $status_text = $statusRow->status;
             $status_fbml[] = "{$status_text}<br>\n";
         } else {
             $status_text = 'is ' . $statusRow->status;
             $status_fbml[] = "{$status_text}<br>\n";
         }
         $theTime = time();
         $updateParams = ProfileApp::timeSinceUpdate($statusRow->modified, time());
         $timeSinceUpdate = $updateParams['value'];
         $timeUnitsSinceUpdate = $updateParams['units'];
         $status_fbml[] = "Updated {$timeSinceUpdate} {$timeUnitsSinceUpdate} ago.\n";
     }
     if ($this->readOnly) {
         $status_fbml[] = "</div>\n";
     } else {
         $status_fbml[] = "<a href='' onClick='toggleEdit{$flavor}();'><img src='" . RingsideApiClientsConfig::$webUrl . "/images/status_icon.gif'/><span style='font-style: normal; font-size: small; vertical-align: top; '>edit</span></a></div>\n";
     }
     $status_fbml[] = "<form id='statusForm{$flavor}' name='statusForm{$flavor}' method='post' style='display: none;' ><fb:name firstnameonly='true' useyou='false' uid='{$this->uid}' />&nbsp;\n";
     $status_fbml[] = "<input name='action' type='hidden' value='saveStatus'/><input name='textfieldStatus' value='{$status_text}' type='text' id='textfieldStatus' size='14' />\n";
     $status_fbml[] = "<a href=\"\" onClick=\"clearField{$flavor}(this);\">Clear Status</a> | <a href=\"\" onClick=\"toggleEdit{$flavor}();\">Cancel</a></form><br>\n";
     $status_fbml[] = "</div><br>";
     return $status_fbml;
 }