public function unDeleteMessage($jobNoteId) { $res = SweteDb::q("update job_notes set `deleted`=0 where job_note_id='" . addslashes($jobNoteId) . "'"); }
function testProcesses() { SweteDb::q('delete from background_processes'); require_once 'inc/BackgroundProcess.php'; $process = new BackgroundProcess(); $this->assertEquals(null, $process->getProcessId()); $this->assertEquals(false, $process->isClean()); $process->save(); $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(0, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); $process->start(); $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertTrue(isset($prec)); if ($prec) { $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(1, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); } $process = new BackgroundProcess(); $this->assertEquals(null, $process->getProcessId()); $this->assertEquals(false, $process->isClean()); $process->save(); $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(0, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); BackgroundProcess::runProcess($process->getProcessId()); $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertTrue(isset($prec)); if ($prec) { $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(1, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); } $process = new BackgroundProcess(); $this->assertEquals(null, $process->getProcessId()); $this->assertEquals(false, $process->isClean()); $process->save(); $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(0, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); $res = BackgroundProcess::runProcesses(); $this->assertTrue($res); if ($res) { $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId())); $this->assertTrue($prec instanceof Dataface_Record); $this->assertTrue(isset($prec)); if ($prec) { $this->assertEquals($process->getProcessId(), $prec->val('process_id')); $this->assertEquals('BackgroundProcess', $prec->val('process_class')); $this->assertEquals(0, intval($prec->val('running'))); $this->assertEquals(1, intval($prec->val('complete'))); $this->assertEquals(0, intval($prec->val('error'))); } } }
public function cleanup() { if ($this->clean) { return; } $this->clean = true; $res = SweteDb::q("select complete from background_processes where process_id='" . addslashes($this->processId) . "'"); if (mysql_num_rows($res) == 0) { error_log("Problem with background process " . $this->processId . ". It could not be found in the table during cleanup."); } else { list($complete) = mysql_fetch_row($res); @mysql_free_result($res); if (!$complete) { SweteDb::q("update background_processes set running=0, error=1, error_message='Process exited without completing. See error log.' where process_id='" . addslashes($this->processId) . "'"); } else { //SweteDb::q("update background_processes set complete=1, running=0, time_finished=NOW() where process_id='".addslashes($this->processId)."'"); } } }
/** * @brief Finds any uncompiled jobs for the current user * * @return array of job records */ static function uncompiledJobs() { require_once 'inc/SweteDb.class.php'; if (!self::getUser()) { return array(); } $res = SweteDb::q("select * from jobs where compiled=false and posted_by ='" . addslashes(self::getUser()->val('username')) . "'"); $jobs = array(); while ($row = mysql_fetch_assoc($res)) { $jobs[] = $row; } @mysql_free_result($res); return $jobs; }
/** * @brief Obtains the default @ref ProxyWriter object for this site. The ProxyWriter * is responsible for actually converting the source HTML that is returned from * the source site into proxified and translated HTML that is output to the user. * * <p>The proxy writer is built and cached on the first request so that * this can be called multiple times to retrieve the same @ref ProxyWriter object.</p> * * @returns ProxyWriter The proxy writer for this class. */ public function getProxyWriter() { if (!isset($this->_proxyWriter)) { import('inc/ProxyWriter.php'); $proxy = new ProxyWriter(); if ($this->_rec->val('translation_parser_version')) { $proxy->translationParserVersion = intval($this->_rec->val('translation_parser_version')); } $proxy->setProxyUrl($this->getProxyUrl()); $proxy->setSrcUrl($this->getSiteUrl()); $res = SweteDb::q("select `name`,`alias` from path_aliases where website_id='" . addslashes($this->_rec->val('website_id')) . "'"); while ($row = mysql_fetch_assoc($res)) { $proxy->addAlias($row['name'], $row['alias']); } $proxy->setSourceLanguage($this->getSourceLanguage()); $proxy->setProxyLanguage($this->getDestinationLanguage()); $proxy->sourceDateLocale = $this->_rec->val('source_date_locale'); $proxy->targetDateLocale = $this->_rec->val('target_date_locale'); $this->_proxyWriter = $proxy; } return $this->_proxyWriter; }
function testGetLiveWebpageTranslatables() { $siteRec = $this->liveSite; $job = $this->createLiveJobWithTranslationMisses(); $translatables = $job->getLiveWebpageTranslatables(); $this->assertEquals(1, sizeof($translatables)); //only 1 result, because all the misses are for the same page/url foreach ($translatables as $t) { //get all the strings for this job_translatable_id $res = SweteDb::q("SELECT http_request_log.request_url, translation_miss_log.normalized_string as string\n\t\t\t\tFROM translation_miss_log\n\t\t\t\tINNER JOIN http_request_log ON translation_miss_log.http_request_log_id = http_request_log.http_request_log_id\n\t\t\t\tWHERE http_request_log.request_url = '" . $t['url'] . "'"); while ($row = mysql_fetch_assoc($res)) { $s = $row['string']; $this->assertTrue($job->containsString($s), 'The job is missing a string that should be there: ' . $s); } } }
public function setStatus($statusId, $postedBy) { try { SweteDb::q("start transaction"); $res = SweteDb::q("insert into job_status_log (job_id, status_id, posted_by, date_posted)\n\t\t\tvalues\n\t\t\t\t(\n\t\t\t\t\t'" . addslashes($this->_rec->val("job_id")) . "',\n\t\t\t\t\t'" . addslashes($statusId) . "',\n\t\t\t\t\t'" . addslashes($postedBy) . "',\n\t\t\t\t\t'" . addslashes(date('Y-m-d H:i:s')) . "'\n\t\t\t\t)"); SweteDb::q("update jobs set job_status='" . addslashes($statusId) . "' where job_id='" . addslashes($this->_rec->val('job_id')) . "'"); SweteDb::q('commit'); } catch (Exception $ex) { SweteDb::q('rollback'); throw $ex; } }