コード例 #1
0
ファイル: swete_message_read.php プロジェクト: gtoffoli/swete
 function handle(&$params)
 {
     // mark the message as read, if hasn't been read yet -job_note_id
     try {
         $app = Dataface_Application::getInstance();
         $query = $app->getQuery();
         $auth =& Dataface_AuthenticationTool::getInstance();
         $user =& $auth->getLoggedInUser();
         $note_id = $query['-job_note_id'];
         $jobNote =& df_get_record("job_notes", array('JobNoteId' => $note_id));
         $job =& df_get_record("jobs", array('job_id' => $jobNote->val('job_id')));
         if (!$job->checkPermission('read message')) {
             throw new Exception("You do not have permission to read this note", E_USER_ERROR);
         }
         require_once 'inc/SweteDb.class.php';
         require_once 'inc/SweteJobInbox.class.php';
         SweteJobInbox::setReadStatic($note_id, $user->val('username'));
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
コード例 #2
0
ファイル: webpage_properties.php プロジェクト: gtoffoli/swete
 function field__webpage($record)
 {
     if (!isset($record->pouch['webpage'])) {
         $record->pouch['webpage'] = df_get_record('webpages', array('webpage_id' => '=' . $record->val('webpage_id')));
     }
     return $record->pouch['webpage'];
 }
コード例 #3
0
ファイル: swete_message_add.php プロジェクト: gtoffoli/swete
 function handle(&$params)
 {
     try {
         // add a new message to the current job record
         //-content is the new message content
         $app = Dataface_Application::getInstance();
         $query = $app->getQuery();
         $auth =& Dataface_AuthenticationTool::getInstance();
         $user =& $auth->getLoggedInUser();
         $content = trim(htmlspecialchars($query['-content']));
         if (!$content) {
             throw new Exception("No message contents entered.", E_USER_ERROR);
         }
         $job_id = $query['-job_id'];
         $job_rec =& df_get_record("jobs", array('job_id' => $job_id));
         if (!$job_rec->checkPermission('add new related record')) {
             throw new Exception("You do not have permission to add a note to this job.", E_USER_ERROR);
         }
         require_once 'inc/SweteDb.class.php';
         require_once 'inc/SweteJob.class.php';
         require_once 'inc/SweteJobInbox.class.php';
         $job = new SweteJob($job_rec);
         $inbox = $job->getInbox($user->val('username'));
         $noteRec = $inbox->addMessage($content);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
コード例 #4
0
 function handle($params)
 {
     session_write_close();
     header('Connection:close');
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     if (@$query['--id']) {
         $table = Dataface_Table::loadTable($query['-table']);
         $keys = array_keys($table->keys());
         if (count($keys) > 1) {
             throw new Exception("Table has compound key so its permissions cannot be retrieved with the --id parameter.");
         }
         $query[$keys[0]] = '=' . $query['--id'];
         $record = df_get_record($query['-table'], $query);
     } else {
         $record = $app->getRecord();
     }
     $perms = array();
     if ($record) {
         $perms = $record->getPermissions();
     }
     header('Content-type: application/json; charset="' . $app->_conf['oe'] . '"');
     $out = json_encode($perms);
     header('Content-Length: ' . strlen($out));
     echo $out;
     flush();
 }
コード例 #5
0
 function handle(&$params)
 {
     try {
         $app = Dataface_Application::getInstance();
         $query = $app->getQuery();
         $selectedRecords = df_get_selected_records($query);
         $isNewJob = false;
         if ($query['-job'] && is_numeric($query['-job'])) {
             $selectedJob = df_get_record('jobs', array('job_id' => '=' . $query['-job']));
         } else {
             //no job was selected by user
             $site_id = $selectedRecords[0]->val('website_id');
             $jobs = df_get_records_array('jobs', array('website_id' => $site_id, 'compiled' => 'false'));
             $createNewJob = false;
             if ($query['-job'] == "new") {
                 $createNewJob = true;
             }
             if (count($jobs) == 0 || $createNewJob) {
                 //create a new job
                 $selectedJob = SweteJob::createJob(SweteSite::loadSiteById($site_id))->getRecord();
                 $isNewJob = true;
             } else {
                 if (count($jobs) == 1) {
                     //only one available job
                     $selectedJob = $jobs[0];
                 } else {
                     throw new Exception("No Job id was specified, but there are " . $count($jobs) . " available jobs to add to");
                 }
             }
         }
         if (!$selectedJob) {
             throw new Exception("Job could not be found", E_USER_ERROR);
         }
         if (!$selectedJob->checkPermission('edit')) {
             throw new Exception("You don't have permission to edit this job");
         }
         $job = new SweteJob($selectedJob);
         $stringsAdded = array();
         foreach ($selectedRecords as $record) {
             if (intval($record->val('website_id')) !== intval($selectedJob->val("website_id"))) {
                 throw new Exception("The string " . $record->val('string') . " is not in the same site as the job.");
             }
             //If string was already added to ANOTHER job, it doesn't matter
             //It will also be added to this one
             //if string was already added to this job, do nothing
             if (!$job->containsString($record->val('string'))) {
                 $job->addTranslationMiss($record->val('translation_miss_log_id'));
                 array_push($stringsAdded, $record->val('string'));
             }
         }
         $results = array('stringsAdded' => $stringsAdded, 'jobId' => $selectedJob->val('job_id'), 'isNewJob' => $isNewJob);
         echo json_encode($results);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
コード例 #6
0
 function handle(&$params)
 {
     try {
         $app = Dataface_Application::getInstance();
         $query = $app->getQuery();
         $jobRecord = df_get_record('jobs', array('job_id' => '=' . $query['-job_id']));
         if (!$jobRecord->checkPermission('edit')) {
             throw new Exception("You do not have permission make changes to this translation job.", E_USER_ERROR);
         }
         $job = new SweteJob($jobRecord);
         if (array_key_exists('-webpage_id', $query)) {
             $webpageRecord = df_get_record('webpages', array('webpage_id' => '=' . $query['-webpage_id']));
             $webpage = new SweteWebpage($webpageRecord);
             $job->removeWebpage($webpage);
         } else {
             if (array_key_exists('-data-http-request-log-id', $query)) {
                 $job->removeRequestStrings($query['-data-http-request-log-id']);
             }
         }
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
コード例 #7
0
ファイル: job_translatable.php プロジェクト: gtoffoli/swete
 function field__website($record)
 {
     $webpage = df_get_record('webpages', array('webpage_id' => '=' . $record->val('webpage_id')));
     if (!$webpage) {
         return null;
     }
     return df_get_record('websites', array('website_id' => '=' . $webpage->val('website_id')));
 }
コード例 #8
0
ファイル: RelatedRecordTest.php プロジェクト: Zunair/xataface
 function test_testCondition()
 {
     require_once 'dataface-public-api.php';
     $record =& df_get_record('People', array('PersonID' => 1));
     $it =& $record->getRelationshipIterator('Publications');
     $pub =& $it->next();
     $this->assertTrue($pub->testCondition('$PublicationID == 1'));
     $this->assertTrue($pub->testCondition('$PubType == "Refereed Journal"'));
     $this->assertTrue(!$pub->testCondition('$PubType == "Journal"'));
 }
コード例 #9
0
ファイル: UtilitiesTest.php プロジェクト: Zunair/xataface
 function test_groupBy()
 {
     $record =& df_get_record('People', array('PersonID' => 1));
     $pubs = $record->getRelatedRecords('Publications', 'all');
     $categories = Dataface_Utilities::groupBy('PubType', $pubs);
     $this->assertEquals(array('Refereed Journal', 'Book Chapter', 'Conference'), array_keys($categories));
     $this->assertEquals(64, sizeof($categories['Refereed Journal']));
     $this->assertEquals(64, sizeof($categories['Book Chapter']));
     $this->assertEquals(63, sizeof($categories['Conference']));
 }
コード例 #10
0
 function handleGet_settingsNotFound($params)
 {
     $website_id = $params['website_id'];
     $settings = df_get_record('websites', array('website_id' => '=' . $website_id));
     if (!$settings) {
         df_display(array(), 'swete/actions/import_webpages/no_settings_found.html');
         return;
     } else {
         df_display(array('settings' => $settings), 'swete/actions/import_webpages/settings_site_not_found.html');
     }
 }
コード例 #11
0
 function handle($params)
 {
     session_write_close();
     header('Connection: close');
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     if (!@$query['-job_translatable_id']) {
         throw new Exception("No translatable id specified");
     }
     $translatable = df_get_record('job_translatable', array('job_translatable_id' => '=' . $query['-job_translatable_id']));
     if (!$translatable) {
         throw new Exception("Translatable could not be found.");
     }
     $job = df_get_record('jobs', array('job_id' => '=' . $translatable->val('job_id')));
     if (!$job) {
         throw new Exception("Job could not be loaded.");
     }
     if (!$job->checkPermission('preview job')) {
         header('HTTP/1.0 401 Forbidden');
         exit;
     }
     require_once 'inc/SweteJob.class.php';
     require_once 'inc/SweteJobPageSucker.php';
     $jobO = new SweteJob($job);
     $pageSucker = new SweteJobPageSucker($jobO);
     $translation = "source";
     if (@$query['-translation']) {
         $translation = $query['-translation'];
     }
     if ($translation == "source") {
         $output = $translatable->val('full_contents');
         $output = $pageSucker->renderHtml($output, DATAFACE_SITE_HREF . '?-action=swete_job_serve_content&job_id=' . $job->val('job_id') . '&url_hash=');
         //$output = $jobO->translateHtml($output, unserialize($job->val('previous_translations')));
     } else {
         if ($translation == "previous") {
             $output = $translatable->val('full_contents');
             $output = $pageSucker->renderHtml($output, DATAFACE_SITE_HREF . '?-action=swete_job_serve_content&job_id=' . $job->val('job_id') . '&url_hash=');
             $output = $jobO->translatePreviousHtml($output, unserialize($job->val('previous_translations')));
         } else {
             if ($translation == "new") {
                 $output = $translatable->val('full_contents');
                 $output = $pageSucker->renderHtml($output, DATAFACE_SITE_HREF . '?-action=swete_job_serve_content&job_id=' . $job->val('job_id') . '&url_hash=');
                 $output = $jobO->translateHtml($output, unserialize($job->val('previous_translations')));
             } else {
                 throw new Exception("Invalid translation parameter " . $translation);
             }
         }
     }
     header('Content-Length: ' . strlen($output));
     header('Content-type: text/html; charset="UTF-8"');
     echo $output;
 }
コード例 #12
0
ファイル: activegrid.php プロジェクト: promoso/HVAC
 /**
  * Creates a grid with the given id or a query.
  * @param mixed $query Either the grid id, or a query array.
  *
  */
 function Dataface_dhtmlxGrid_activegrid($query, $name = 'mygrid')
 {
     // We are building a grid from a Dataface Query array.
     $q =& $query;
     if (isset($q['-columns'])) {
         if (is_array($q['-columns'])) {
             $columns = $q['-columns'];
         } else {
             $columns = explode(',', $q['-columns']);
         }
     } else {
         $columns = null;
     }
     if (isset($q['-records'])) {
         $this->Dataface_dhtmlxGrid_grid($columns, $q['-records'], $name, $q['-parent_id'], $q['-relationship']);
     } else {
         if (isset($q['-relationship'])) {
             // We are looking at the related records of a particular record.
             $record = df_get_record($q['-table'], $q);
             $records = $record->getRelatedRecordObjects($q['-relationship']);
             // We want the keys to be unique identifiers for the record that it
             // points to, so we will rekey the array using the
             // Dataface_RelatedRecord::getId() method
             //$related_records = $this->keyById($related_records);
             if (!$columns) {
                 $table =& Dataface_Table::loadTable($q['-table']);
                 $relationship =& $table->getRelationship($q['-relationship']);
                 $columns = $relationship->getColumnNames();
             }
             $this->Dataface_dhtmlxGrid_grid($columns, $records, $name, $record->getId(), $q['-relationship']);
             // now that we have created the grid.. we need to generate
             // and id for it and save the data in session vars
         } else {
             // We are not looking for related records - we are looking for
             // actual records.
             $records = df_get_records_array($q['-table'], $q);
             // We want the keys to be unique identifiers for the record that
             // it points to, so we will rekey the array using the
             // Dataface_Record::getId() method.
             //$records = $this->keyById($records);
             if (!$columns) {
                 $table =& Dataface_Table::loadTable($q['-table']);
                 $columns = $table->fields();
             }
             $this->Dataface_dhtmlxGrid_grid($columns, $records, $name, $q['-table']);
         }
     }
     $this->id = $this->update(null);
 }
コード例 #13
0
ファイル: TreeTableTest.php プロジェクト: Zunair/xataface
 function setUp()
 {
     parent::setUp();
     xf_db_query("CREATE TABLE `Pages` (\n\t\t\t`PageID` INT(11) auto_increment NOT NULL,\n\t\t\t`ParentID` INT(11),\n\t\t\t`ShortName` VARCHAR(32) NOT NULL,\n\t\t\t`Description` TEXT,\n\t\t\tPRIMARY KEY (`PageID`),\n\t\t\tUNIQUE (`ParentID`,`ShortName`))") or trigger_error(xf_db_error() . __LINE__);
     xf_db_query("INSERT INTO `Pages` (`PageID`,`ShortName`,`Description`)\n\t\t\tVALUES (1,'index_page','Main page')") or trigger_error(xf_db_error() . __LINE__);
     xf_db_query("INSERT INTO `Pages` (`ParentID`,`ShortName`,`Description`)\n\t\t\tVALUES \n\t\t\t(1,'about','About us'),\n\t\t\t(1,'jobs','Now hiring'),\n\t\t\t(1,'products','About our products'),\n\t\t\t(1,'services','About our services'),\n\t\t\t(1,'contact','Contact us')") or trigger_error(xf_db_error() . __LINE__);
     xf_db_query("INSERT INTO `Pages` (`ParentID`,`ShortName`,`Description`)\n\t\t\tVALUES\n\t\t\t(2,'history','Our history'),\n\t\t\t(2,'future', 'The direction of the company'),\n\t\t\t(3,'application', 'Job application'),\n\t\t\t(3,'current_listing', 'Current job listings'),\n\t\t\t(4,'awards','Product awards'),\n\t\t\t(4,'downloads','Product downlaods'),\n\t\t\t(5,'consultation','Free consultation')") or trigger_error(xf_db_error() . __LINE__);
     $table =& Dataface_Table::loadTable('Pages');
     $r =& $table->relationships();
     if (!isset($r['children'])) {
         $table->addRelationship('children', array('__sql__' => 'select * from Pages where ParentID=\'$PageID\'', 'meta:class' => 'children'));
     }
     $this->indexpage =& df_get_record('Pages', array('PageID' => 1));
     $this->t = new Dataface_TreeTable($this->indexpage);
 }
コード例 #14
0
ファイル: swete_tool_bar.php プロジェクト: gtoffoli/swete
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $website = df_get_record('websites', array('website_id' => '=' . $query['website_id']));
     if (!$website) {
         throw new Exception("Website could not be found.");
     }
     if (!$website->checkPermission('capture strings')) {
         return Dataface_Error::permissionDenied("You don't have permission to perform this action.");
     }
     Dataface_JavascriptTool::getInstance()->import('swete/actions/swete_tool_bar.js');
     import('inc/SweteSite.class.php');
     df_display(array('website' => $website, 'websiteWrapper' => new SweteSite($website)), 'swete/actions/toolbar_wrapper.html');
 }
コード例 #15
0
ファイル: swete_messages.php プロジェクト: gtoffoli/swete
 function handle(&$params)
 {
     // returns html for a table with all the messages for -job_id
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $auth =& Dataface_AuthenticationTool::getInstance();
     $user =& $auth->getLoggedInUser();
     $job_id = $query['-job_id'];
     $job =& df_get_record("jobs", array('job_id' => $job_id));
     require_once 'inc/SweteDb.class.php';
     require_once 'inc/SweteJob.class.php';
     require_once 'inc/SweteJobInbox.class.php';
     require_once 'inc/SweteJobInboxPresentation.php';
     $sweteJob = new SweteJob($job);
     $messageList = $sweteJob->getInbox($user->val('username'))->getMessageList();
     echo SweteJobInboxPresentation::tableContent($messageList);
 }
コード例 #16
0
ファイル: CopyTool.php プロジェクト: minger11/Pipeline
 function copy($record, $vals = array(), $force = true)
 {
     foreach ($vals as $k => $v) {
         if (strpos($v, '=') === 0) {
             $vals[$k] = $this->evaluate($v, $k, $record);
         }
     }
     $del = $record->_table->getDelegate();
     if (isset($del) and method_exists($del, 'beforeCopy')) {
         $res = $del->beforeCopy($record, $vals);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     $this->warnings = array();
     // Step 1: Load the record - it has been passed
     // Step 2: build sql query to copy the record
     $query = $this->buildCopyQuery($record, $vals, $force);
     if (PEAR::isError($query)) {
         return $query;
     }
     $res = df_query($query);
     if (!$res) {
         return PEAR::raiseError("Failed to copy record '" . $record->getTitle() . "' due to an SQL error:" . xf_db_error());
     }
     if (PEAR::isError($res)) {
         return $res;
     }
     $ret = null;
     if ($auto_field_id = $record->_table->getAutoIncrementField()) {
         $insert_id = df_insert_id();
         $copied =& df_get_record($record->_table->tablename, array($auto_field_id => $insert_id));
         $ret = $copied;
     } else {
         $ret = new Dataface_Record($record->_table->tablename, array_merge($record->vals(), $vals));
     }
     if (isset($del) and method_exists($del, 'afterCopy')) {
         $res = $del->afterCopy($record, $ret);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     return $ret;
 }
コード例 #17
0
 function handle($params)
 {
     session_write_close();
     header('Connection: close');
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     if (!@$query['job_id']) {
         throw new Exception("NO job id specified");
     }
     if (!@$query['url_hash']) {
         throw new Exception("No URL Hash specified");
     }
     $job = df_get_record('jobs', array('job_id' => '=' . $query['job_id']));
     if (!$job) {
         throw new Exception("Job could not be found.");
     }
     require_once 'inc/SweteJob.class.php';
     require_once 'inc/SweteJobPageSucker.php';
     $jobO = new SweteJob($job);
     $pageSucker = new SweteJobPageSucker($jobO);
     $resource = $pageSucker->loadResource($query['url_hash']);
     if (!$resource) {
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     if (!$job->checkPermission('preview job')) {
         header('HTTP/1.0 400 Permission denied');
         exit;
     }
     $res = df_q("select * from job_content where job_content_id='" . addslashes($resource->val('job_content_id')) . "' limit 1");
     $content = mysql_fetch_object($res);
     $output = $content->content;
     if (preg_match('#css#', $content->content_type)) {
         $output = $pageSucker->renderCss($output, DATAFACE_SITE_HREF . '?-action=swete_job_serve_content&job_id=' . $query['job_id'] . '&url_hash=');
     }
     header('Content-Length: ' . strlen($output));
     header('Content-Type: ' . $content->content_type);
     echo $output;
     flush();
 }
コード例 #18
0
 function handle(&$params)
 {
     // delete the message for -job_note_id
     try {
         $app = Dataface_Application::getInstance();
         $query = $app->getQuery();
         $note_id = $query['-job_note_id'];
         $jobNote =& df_get_record("job_notes", array('JobNoteId' => $note_id));
         if (!$jobNote->checkPermission('delete')) {
             throw new Exception("You do not have permission to delete this note", E_USER_ERROR);
         }
         require_once 'inc/SweteDb.class.php';
         require_once 'inc/SweteJobInbox.class.php';
         SweteJobInbox::deleteMessage($note_id);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
コード例 #19
0
 function handle($params)
 {
     $query = Dataface_Application::getInstance()->getQuery();
     if (!isset($query['website_id'])) {
         throw new Exception("No site id provided");
     }
     $site = df_get_record('websites', array('website_id' => '=' . $query['website_id']));
     if (!$site->checkPermission('view')) {
         throw new Exception("No permission to perform action");
     }
     import('Dataface/ResultReader.php');
     $reader = new Dataface_ResultReader("select\n\t\t\tws.source_language,\n\t\t\tws.target_language,\n\t\t\tws.log_translation_misses,\n\t\t\tws.website_id, \n\t\t\tws.website_name,\n\t\t\tws.website_url,\n\t\t\tws.translation_memory_id,\n\t\t\tconcat('http://',ws.host,ws.base_path) as proxy_url,\n\t\t\tws.source_language,\n\t\t\tws.target_language,\n\t\t\t(\n\t\t\t\tselect count(*) from webpages w where w.website_id=ws.website_id\n\t\t\t) as numpages,\n\t\t\t(\n\t\t\t\tselect count(*) from swete_strings tml where tml.website_id=ws.website_id\n\t\t\t) as numphrases,\n\t\t\tifnull((\n\t\t\t\tselect sum(tml.num_words) from xf_tm_strings xts \n\t\t\t\t\tinner join swete_strings tml on tml.string_id=xts.string_id\n\t\t\t\twhere tml.website_id=ws.website_id\n\t\t\t), 0) as numwords,\n\t\t\t(\n\t\t\t\tselect count(*) from swete_strings tml\n\t\t\t\t\tinner join websites ws2 on ws2.website_id=tml.website_id\n\t\t\t\t\tinner join xf_tm_translation_memory_strings xttms on xttms.translation_memory_id=ws2.translation_memory_id and xttms.string_id=tml.string_id\n\t\t\t\twhere xttms.current_translation_id is not null\n\t\t\t\t \tand tml.website_id=ws.website_id\n\t\t\t\t\n\t\t\t) as translated_phrases,\n\t\t\t\n\t\t\tifnull((\n\t\t\t\tselect sum(tml.num_words) from swete_strings tml\n\t\t\t\t\tinner join websites ws2 on ws2.website_id=tml.website_id\n\t\t\t\t\tinner join xf_tm_translation_memory_strings xttms on xttms.translation_memory_id=ws2.translation_memory_id and xttms.string_id=tml.string_id\n\t\t\t\t\tinner join xf_tm_strings xts on xttms.string_id=xts.string_id\n\t\t\t\twhere xttms.current_translation_id is not null\n\t\t\t\t\tand tml.website_id=ws.website_id\n\t\t\t\t\t\n\t\t\t), 0) as translated_words\n\t\t\t\n\t\t\t\t\n\t\t\tfrom websites ws where website_id='" . addslashes($query['website_id']) . "'\n\t\t\t", df_db());
     $results = array();
     //$languages = Dataface_Table::loadTable('websites')->getValuelist('languages');
     foreach ($reader as $row) {
         $results[] = $row;
         $row->untranslated_words = $row->numwords - $row->translated_words;
         $row->untranslated_phrases = $row->numphrases - $row->translated_phrases;
         //$row->source_label = @$languages[$row->source_language] ? $languages[$row->source_language] : $row->source_language;
         //$row->target_label = @$languages[$row->target_language] ? $languages[$row->target_language] : $row->target_language;
     }
     df_display(array('results' => $results), 'swete/actions/dashboard_site_stats.html');
 }
コード例 #20
0
    public function tableContent($messageList)
    {
        if (count($messageList) == 0) {
            //no rows
            $content = "";
        } else {
            $content = '<tr>
						<th>Note</th>
						<th>Date Posted</th>
						<th>Posted By</th>
						<th>Read On</th>';
            $content .= '<th></th>';
            //delete column
            $content .= '		<th></th>
				 </tr>';
            foreach ($messageList as $message) {
                if ($message->read) {
                    $tr_class = "read";
                } else {
                    $tr_class = "unread";
                }
                $content .= '<tr class="job-message-data ' . $tr_class . '" data-note-id=' . $message->note_id . '>
					<td class="job-message-content">' . $message->note_content . '</td>
					<td>' . $message->date_posted . '</td>
					<td>' . $message->posted_by . '</td>
					<td class="date-read">' . $message->date_read . '</td>';
                $jobNote =& df_get_record("job_notes", array('JobNoteId' => $message->job_note_id));
                if ($jobNote->checkPermission('delete')) {
                    $content .= '<td class="delete message-action">Delete</td>';
                } else {
                    $content .= '<td></td>';
                }
                $content .= '<td class="show-hide message-action">Show/Hide</td></tr>';
            }
        }
        return $content;
    }
コード例 #21
0
ファイル: forgot_password.php プロジェクト: Zunair/xataface
    public function reset_password_with_uuid($uuid)
    {
        $auth = Dataface_AuthenticationTool::getInstance();
        $app = Dataface_Application::getInstance();
        $del = $app->getDelegate();
        $this->create_reset_password_table();
        $this->clear_expired();
        $table = self::$TABLE_RESET_PASSWORD;
        $res = xf_db_query("select * from `{$table}` where request_uuid='" . addslashes($uuid) . "' limit 1", df_db());
        if (!$res) {
            throw new Exception(xf_db_error(df_db()));
        }
        $row = xf_db_fetch_assoc($res);
        if (!$row) {
            throw new Exception(df_translate('actions.forgot_password.no_such_reset_request_found', "No such reset request could be found"), self::$EX_NO_SUCH_UUID);
        }
        if (!$row['username']) {
            throw new Exception(df_translate('actions.forgot_password.attempt_to_reset_for_null_username', "Attempt to reset password for user with null username"), self::$EX_NO_USERNAME_FOR_USER);
        }
        $username = $row['username'];
        @xf_db_free_result($res);
        // now that we have the username, let's reset the password.
        //$rand = strval(rand())."".$uuid;
        $rand = md5($uuid);
        error_log("Rand is " . $rand);
        $pw = '';
        for ($i = 0; $i <= 16; $i += 2) {
            $pw .= $rand[$i];
        }
        $password = $pw;
        if (isset($del) and method_exists($del, 'generateTemporaryPassword')) {
            $pw = $del->generateTemporaryPassword();
            if ($pw) {
                $password = $pw;
            }
        }
        //error_log("Password is $password");
        $user = df_get_record($auth->usersTable, array($auth->usernameColumn => '=' . $username));
        if (!$user) {
            throw new Exception(df_translate('actions.forgot_password.no_account_for_username', "No user account found with that username"), self::$EX_USER_NOT_FOUND);
        }
        $emailColumn = $auth->getEmailColumn();
        if (!$emailColumn) {
            throw new Exception(df_translate('actions.forgot_password.no_email_column_found_short', "No email column found in the users table"), self::$EX_NO_EMAIL_COLUMN_FOUND);
        }
        $email = $user->val($emailColumn);
        if (!$email) {
            throw new Exception(df_translate('actions.forgot_password.user_without_email_long', "User has account has no email address on record.  Please contact support to reset the password"), self::$EX_NO_EMAIL_FOR_USER);
        }
        $user->setValue($auth->passwordColumn, $password);
        $res = $user->save();
        if (PEAR::isError($res)) {
            throw new Exception($res->getMessage());
        }
        // Let's delete this request from the password reset requests.
        $this->delete_request_with_uuid($uuid);
        // Now let's send the email.
        $del = $app->getDelegate();
        $info = array();
        if (isset($del) and method_exists($del, 'getPasswordChangedEmailInfo')) {
            $info = $del->getPasswordChangedEmailInfo($user, $password);
        }
        $subject = df_translate('actions.forgot_password.password_changed', "Password Changed");
        if (isset($info['subject'])) {
            $subject = $info['subject'];
        }
        $site_url = df_absolute_url(DATAFACE_SITE_HREF);
        $msg = df_translate('actions.forgot_password.new_temporary_password_email_body', <<<END
Your new temporary password is
{$password}

You can change your password as follows:

1. Log in with your temporary password at <{$site_url}?-action=login>
2. Click on the "My Profile" link in the upper right of the page
3. Click on the "Edit" tab.
4. Change your password in the edit form and click "Save" when done.
END
, array('password' => $password, 'site_url' => $site_url));
        if (isset($info['message'])) {
            $msg = $info['message'];
        }
        $parameters = null;
        if (isset($info['parameters'])) {
            $parameters = $info['parameters'];
        }
        $site_title = $app->getSiteTitle();
        $support_email = $_SERVER['SERVER_ADMIN'];
        if (isset($app->_conf['admin_email'])) {
            $support_email = $app->_conf['admin_email'];
        }
        if (isset($app->_conf['support_email'])) {
            $support_email = $app->_conf['support_email'];
        }
        $headers = 'From: ' . $site_title . ' <' . $support_email . '>' . "\r\nReply-to: " . $site_title . " <" . $support_email . ">" . "\r\nContent-type: text/plain; charset=" . $app->_conf['oe'];
        if (isset($info['headers'])) {
            $headers = $info['headers'];
        }
        if (@$app->_conf['_mail']['func']) {
            $func = $app->_conf['_mail']['func'];
        } else {
            $func = 'mail';
        }
        $res = $func($email, $subject, $msg, $headers, $parameters);
        if (!$res) {
            return PEAR::raiseError(df_translate('actions.forgot_password.failed_send_activation', "Failed to send activation email.  Please try again later."), DATAFACE_E_ERROR);
        } else {
            return true;
        }
    }
コード例 #22
0
ファイル: webpages.php プロジェクト: gtoffoli/swete
 function field__website($record)
 {
     return df_get_record('websites', array('website_id' => '=' . $record->val('website_id')));
 }
コード例 #23
0
ファイル: jobs.php プロジェクト: gtoffoli/swete
 function afterRemoveRelatedRecord($relatedRecord)
 {
     //remove the webpage strings fro the job
     //todo only for 'webpages' related record
     error_log("afterRemoveRelatedRecord table is " . $relatedRecord->_record->_tableName);
     //if ($relatedRecord->_record->_tableName == 'webpages'){
     require_once 'inc/SweteJob.class.php';
     require_once 'inc/SweteWebpage.class.php';
     require_once 'inc/SweteDb.class.php';
     $jobsRecord = $relatedRecord->toRecord('jobs');
     $job = new SweteJob($jobsRecord);
     $webpageRecord = df_get_record("webpages", array('webpage_id' => $relatedRecord->toRecord('webpages')->val("webpage_id")));
     $job->removeWebpage(new SweteWebpage($webpageRecord));
 }
コード例 #24
0
ファイル: Table.php プロジェクト: promoso/HVAC
 /**
  * Gets a record from the database that matches the given query.
  * @param $query associative array of key/value search terms.
  */
 function &getRecord($query = null)
 {
     return df_get_record($this->tablename, $query);
 }
コード例 #25
0
ファイル: RecordTest2.php プロジェクト: Zunair/xataface
 function test_getLength()
 {
     $record =& df_get_record('People', array('PersonID' => 1));
     $this->assertEquals(20, $record->getLength('Name'));
     $this->assertEquals(107, $record->getLength('Publications.BiblioString', 10));
     $this->assertEquals(107, $record->getLength('Publications.BiblioString', 10, 'PublicationID>1'));
     $this->assertEquals(107, $record->getLength('Publications.BiblioString', 10, 'PublicationID>1', 'BiblioString'));
 }
コード例 #26
0
 function getSite($id)
 {
     if (!isset($this->sites[$id])) {
         $this->sites[$id] = df_get_record('websites', array('website_id' => '=' . $id));
     }
     return $this->sites[$id];
 }
コード例 #27
0
 function test_newCanonicalVersion()
 {
     $record = df_get_record('Profiles', array('id' => 10));
     $tt = new Dataface_TranslationTool();
     $this->assertEquals('2.00', $tt->markNewCanonicalVersion($record, 'en'));
     $this->assertEquals('3.00', $tt->markNewCanonicalVersion($record, 'en'));
     $this->assertEquals('2.00', $tt->markNewCanonicalVersion($record, 'fr'));
 }
コード例 #28
0
ファイル: HistoryTool.php プロジェクト: minger11/Pipeline
 /**
  * Obtains a record from the history table given the value in the history__id column.
  * @param string $tablename The name of the base table.
  * @param integer $id The id (history__id column value).
  * @returns Dataface_Record from the history table.
  */
 function getRecordById($tablename, $id)
 {
     $htablename = $tablename . '__history';
     if (!Dataface_Table::tableExists($htablename)) {
         return PEAR::raiseError(df_translate('scripts.Dataface.HistoryTool.getDiffs.ERROR_HISTORY_TABLE_DOES_NOT_EXIST', "History table for '{$tablename}' does not exist, so we cannot obtain changes for records of that table.", array('tablename' => $tablename)), DATAFACE_E_ERROR);
     }
     $rec = df_get_record($htablename, array('history__id' => $id));
     return $rec;
 }
コード例 #29
0
 function handle(&$params)
 {
     session_write_close();
     header('Connection: close');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $table = $query['-table'];
     $ids = $query['-id'];
     $rec = null;
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $out = array();
     foreach ($ids as $id) {
         if (preg_match('/^' . preg_quote($table, '/') . '\\?/', $id)) {
             // This is a record id
             $rec = df_get_record_by_id($id);
         } else {
             if (strpos($id, '=') !== false) {
                 parse_str($id, $q);
                 $rec = df_get_record($table, $q);
             } else {
                 $keys = array_keys(Dataface_Table::loadTable($table)->keys());
                 $q = array($keys[0] => '=' . $id);
                 $rec = df_get_record($table, $q);
             }
         }
         if ($rec) {
             header('Content-type: text/html; charset=' . $app->_conf['oe']);
             if ($rec->checkPermission('view')) {
                 switch (strval(@$query['-text'])) {
                     case '':
                     case '__title__':
                         $out[] = $rec->getTitle();
                         break;
                     case '__json__':
                         //header('Content-type: text/json; charset='.$app->_conf['oe']);
                         $out[] = array_merge($rec->strvals(), array('__id__' => $rec->getId()));
                         break;
                     default:
                         $out[] = $rec->display($query['-text']);
                         break;
                 }
             } else {
                 return Dataface_Error::permissionDenied('You require view permission to access this record');
             }
         }
     }
     if (count($out) == 0) {
         $out[] = "";
     }
     if (count($out) < 2 and !is_array($query['-id']) and @$query['-return-type'] != 'array') {
         if (@$query['-text'] == '__json__') {
             header("Content-type: application/json; charset=" . $app->_conf['oe']);
             echo json_encode($out[0]);
         } else {
             echo $out[0];
         }
     } else {
         header("Content-type: application/json; charset=" . $app->_conf['oe']);
         echo json_encode($out);
     }
     exit;
 }
コード例 #30
0
 function loadSingle(Dataface_Table $table, &$field, $query)
 {
     try {
         if (!@$query['-depselect-id']) {
             throw new Exception("Please specify the -depselect-id parameter");
         }
         $perms = $table->getPermissions(array('field' => $field['name']));
         if (!@$perms['view']) {
             error_log("Insufficient permissions to access field {$field['name']} by current user.");
             throw new Exception("Failed to get value for depselect because you don't have view permission");
         }
         $targetTable = Dataface_Table::loadTable($field['widget']['table']);
         $keyCol = null;
         $labelCol = null;
         if (@$field['widget']['keycol']) {
             $keyCol = $field['widget']['keycol'];
         } else {
             foreach ($targetTable->keys() as $k => $v) {
                 $keyCol = $k;
                 break;
             }
         }
         if (!$keyCol) {
             throw new Exception("No key column found in table " . $field['widget']['table']);
         }
         $rec = df_get_record($field['widget']['table'], array($keyCol => '=' . $query['-depselect-id']));
         if (!$rec) {
             throw new Exception("No such record found", 404);
         }
         $value = null;
         if (@$field['widget']['ignore_permissions']) {
             $rec->secureDisplay = false;
         }
         if ($labelCol) {
             $value = $rec->display($labelCol);
         } else {
             $value = $rec->getTitle();
         }
         $this->out(array('code' => 200, 'message' => 'Value successfully found', 'value' => $value));
         exit;
     } catch (Exception $ex) {
         $this->out(array('code' => $ex->getCode(), 'message' => $ex->getMessage()));
         exit;
     }
 }