Esempio n. 1
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     if (!isset($_POST['--confirm_invalidate'])) {
         return PEAR::raiseError("Cannot invalidate translations with a GET request.  Please provide the POST parameter '--confirm_invalidate'");
     }
     $record =& $app->getRecord();
     if (!$record) {
         return PEAR::raiseError("Attempt to invalidate translations on null record.  No record could be found to match the query parameters.");
     }
     import('Dataface/TranslationTool.php');
     $tt = new Dataface_TranslationTool();
     $res = $tt->markNewCanonicalVersion($record, $app->_conf['default_language']);
     if (PEAR::isError($res)) {
         return $res;
     }
     $query =& $app->getQuery();
     if (isset($query['--redirect'])) {
         header('Location: ' . $query['--redirect'] . '&--msg=' . urlencode("Translations successfully invalidated."));
         exit;
     } else {
         header('Location: ' . $record->getURL('-action=edit') . '&--msg=' . urlencode('Translations successfully invalidated.'));
         exit;
     }
 }
Esempio n. 2
0
    function toHtml()
    {
        $id = rand(10, 100000);
        $app =& Dataface_Application::getInstance();
        $p = $this->prefix;
        if (@$app->prefs['default_collapse_sort_control']) {
            $out = '<a href="#" onclick="document.getElementById(\'Dataface_SortControl-' . $id . '\').style.display=\'\'; this.style.display=\'none\'; return false">Sort Results</a>';
            $style = 'display:none';
        } else {
            $style = '';
        }
        $out .= '<div style="' . $style . '" id="Dataface_SortControl-' . $id . '" class="Dataface_SortControl"><fieldset><legend>Sorted on:</legend><ul class="Dataface_SortControl_current_sort-list">
				';
        foreach ($this->current_sort as $fieldname => $dir) {
            $fieldDef = $this->table->getField($fieldname);
            $out .= '<li>
			
			<a class="Dataface_SortControl-reverse-' . $dir . '" href="' . $app->url('-' . $p . 'sort=' . urlencode($this->reverseSortOn($fieldname))) . '" title="Sort the results in reverse order on this column"><img src="' . DATAFACE_URL . '/images/' . ($dir == 'asc' ? 'arrowUp.gif' : 'arrowDown.gif') . '"/>' . $fieldDef['widget']['label'] . '</a>
			<a href="' . $app->url('-' . $p . 'sort=' . urlencode($this->removeParameter($fieldname))) . '" title="Remove this field from the sort parameters"><img src="' . DATAFACE_URL . '/images/delete.gif"/></a>
			</li>';
        }
        $out .= '</ul>';
        $out .= '<select onchange="window.location=this.options[this.selectedIndex].value">
			<option value="">Add Columns</th>';
        foreach ($this->fields as $fieldname) {
            $fieldDef = $this->table->getField($fieldname);
            $out .= '<option value="' . $app->url('-' . $p . 'sort=' . urlencode($this->addParameter($fieldname))) . '">' . $fieldDef['widget']['label'] . '</option>';
        }
        $out .= '</select><div style="clear:both"></div></fieldset></div>';
        return $out;
    }
    /**
     * @brief Initializes the datepicker module and registers all of the event listener.
     *
     */
    function __construct()
    {
        $app = Dataface_Application::getInstance();
        // Now work on our dependencies
        $mt = Dataface_ModuleTool::getInstance();
        // We require the XataJax module
        // The XataJax module activates and embeds the Javascript and CSS tools
        $mt->loadModule('modules_XataJax', 'modules/XataJax/XataJax.php');
        // Register the geopicker widget with the form tool so that it responds
        // to widget:type=geopicker
        import('Dataface/FormTool.php');
        $ft = Dataface_FormTool::getInstance();
        $ft->registerWidgetHandler('geopicker', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widget.php', 'Dataface_FormTool_geopicker');
        if (!@$app->_conf['modules_geopicker'] or !@$app->_conf['modules_geopicker']['key']) {
            $msg = <<<END
                 <p>Google Maps Module is installed but no API key is specified.</p>
                 <p>For information about obtaining your API key see <a href="https://developers.google.com/maps/documentation/javascript/tutorial#api_key">this page</a>.</p>
                 <p>After obtaining your key, add the following section to your application's conf.ini file:</p>
                 <p><code><pre>
[modules_geopicker]
    key=YOUR_API_KEY_HERE
                    </pre></code></p>
END;
            die($msg);
        }
        $app->addHeadContent('<script>XF_GEOPICKER_API_KEY="' . htmlspecialchars($app->_conf['modules_geopicker']['key']) . '";</script>');
        foreach (Dataface_Table::loadTable('', df_db(), true) as $t) {
            $evt = new StdClass();
            $evt->table = $t;
            $this->afterTableInit($evt);
        }
        $app->registerEventListener("afterTableInit", array($this, 'afterTableInit'));
        $app->registerEventListener("Dataface_Record__htmlValue", array($this, 'Dataface_Record__htmlValue'));
    }
 function handle(&$params)
 {
     try {
         $app = Dataface_Application::getInstance();
         $query =& $app->getQuery();
         $jt = Dataface_JavascriptTool::getInstance();
         $jt->import('swete/ui/filter_translations.js');
         $app->addHeadContent('<link rel="stylesheet" type="text/css" href="css/swete/actions/review_translations.css"/>');
         if (!@$query['-recordid']) {
             throw new Exception("No record id was specified");
         }
         $record = df_get_record_by_id($query['-recordid']);
         $job = new SweteJob($record);
         $tm = XFTranslationMemory::loadTranslationMemoryFor($record, $record->val('source_language'), $record->val('destination_language'));
         $translations = $job->getTranslations();
         $template = 'swete/actions/review_translations.html';
         if (@$query['-isDialog']) {
             $template = 'swete/actions/review_translations_dlg.html';
         }
         df_display(array('job' => $job, 'translations' => $translations), $template);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     if (!@$_POST['-valuelist']) {
         echo JSON::error("No valuelist specified.");
         exit;
     }
     $valuelist = $_POST['-valuelist'];
     $query =& $app->getQuery();
     $table =& Dataface_Table::loadTable($query['-table']);
     if (!@$_POST['-value']) {
         echo JSON::error("No value was provided to be appended to the valuelist.");
         exit;
     }
     $value = $_POST['-value'];
     if (@$_POST['-key']) {
         $key = $_POST['-key'];
     } else {
         $key = null;
     }
     $vt =& Dataface_ValuelistTool::getInstance();
     $res = $vt->addValueToValuelist($table, $valuelist, $value, $key, true);
     if (PEAR::isError($res)) {
         echo JSON::error($res->getMessage());
         exit;
     }
     echo JSON::json(array('success' => 1, 'value' => array('key' => $res['key'], 'value' => $res['value'])));
     exit;
 }
Esempio n. 6
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $app->_handleGetBlob($query);
     exit;
 }
 function handle(&$params)
 {
     try {
         $app =& Dataface_Application::getInstance();
         $query =& $app->getQuery();
         if (isset($query['-record-id'])) {
             //todo fix the php notice here. Undefined index: -record-id
             $selectedRecord = df_get_record_by_id($query['-record-id']);
             echo $selectedRecord->val('website_id');
         } else {
             $selectedRecords = df_get_selected_records($query);
             if (empty($selectedRecords)) {
                 throw new Exception("No records specified");
             }
             $record = $selectedRecords[0];
             $websiteId = $record->val('website_id');
             //ensure that all selectedRecords are for the same website
             foreach ($selectedRecords as $record) {
                 if ($record->val('website_id') != $websiteId) {
                     throw new Exception("All records must be from the same site.", E_USER_ERROR);
                 }
             }
             //return the website id
             echo $websiteId;
         }
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
 public function beforeHandleRequest()
 {
     $query =& Dataface_Application::getInstance()->getQuery();
     if ($query['-action'] !== 'friends_api') {
         $query['-action'] = 'install_app';
     }
 }
Esempio n. 9
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     if (!$record) {
         echo '{}';
     }
     $relationships = $record->_table->getRelationshipsAsActions();
     if (isset($_GET['-relationship'])) {
         $relationships = array($relationships[$_GET['-relationship']]);
     }
     $outerOut = array();
     foreach ($relationships as $relationship) {
         $innerOut = array();
         $relatedRecords = $record->getRelatedRecordObjects($relationship['name'], 0, 60);
         foreach ($relatedRecords as $relatedRecord) {
             $domainRecord = $relatedRecord->toRecord();
             $innerOut[] = "'" . $domainRecord->getId() . "': " . $domainRecord->toJS(array());
         }
         if (count($relationships) > 1) {
             $outerOut[] = "'" . $relationship['name'] . "': {'__title__': '" . $relationship['label'] . "', '__url__': '" . $record->getURL('-action=related_records_list&-relationship=' . urlencode($relationship['name'])) . "','records': {" . implode(',', $innerOut) . "}}";
         } else {
             $outerOut[] = implode(',', $innerOut);
         }
     }
     echo '{' . implode(',', $outerOut) . '}';
     exit;
 }
Esempio n. 10
0
 function handle(&$params)
 {
     session_write_close();
     header('Connection: close');
     $app = Dataface_Application::getInstance();
     try {
         $query =& $app->getQuery();
         if (!@$query['-record-id']) {
             throw new Exception("No record id was specified");
         }
         $record = df_get_record_by_id($query['-record-id']);
         $username = $query['-username'];
         if (!$username) {
             throw new Exception("No username was specified");
         }
         if ($record->val('compiled') == 0) {
             throw new Exception("The job has must be compiled before it can be approved");
         }
         if ($record->val('job_status') == SweteJob::JOB_STATUS_CLOSED) {
             throw new Exception("The job has already been approved");
         }
         $job = new SweteJob($record);
         $job->approve($username);
         $out = array('code' => 200, 'message' => 'Successfully approved your job ');
     } catch (Exception $ex) {
         $out = array('code' => $ex->getCode(), 'message' => $ex->getMessage());
     }
     header('Content-type: text/json; charset="' . $app->_conf['oe'] . '"');
     echo json_encode($out);
     return;
 }
Esempio n. 11
0
 function handle($params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     if (!isset($query['-relationship'])) {
         return PEAR::raiseError("No relationship specified.");
     }
     $table =& Dataface_Table::loadTable($query['-table']);
     $record =& $app->getRecord();
     if (!$record) {
         return Dataface_Error::permissionDenied("No record found");
     }
     $perms = $record->getPermissions(array('relationship' => $query['-relationship']));
     if (!@$perms['view related records']) {
         return Dataface_Error::permissionDenied('You don\'t have permission to view this relationship.');
     }
     $action = $table->getRelationshipsAsActions(array(), $query['-relationship']);
     if (isset($query['-template'])) {
         df_display(array('record' => $record), $query['-template']);
     } else {
         if (isset($action['template'])) {
             df_display(array('record' => $record), $action['template']);
         } else {
             df_display(array('record' => $record), 'Dataface_Related_Records_List.html');
         }
     }
 }
Esempio n. 12
0
 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;
         }
     }
 }
 function handle($params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $record =& $app->getRecord();
     if (!$record) {
         return PEAR::raiseError("No record found.", DATAFACE_E_NOTICE);
     }
     if (!isset($query['-relationship'])) {
         return PEAR::raiseError("No relationship specified.");
     }
     $table =& Dataface_Table::loadTable($query['-table']);
     $action = $table->getRelationshipsAsActions(array(), $query['-relationship']);
     if (@$action['permission'] and !$record->checkPermission($action['permission'])) {
         return Dataface_Error::permissionDenied();
     }
     ob_start();
     import('Dataface/RelationshipCheckboxForm.php');
     $form = new Dataface_RelationshipCheckboxForm($record, $query['-relationship']);
     $out = ob_get_contents();
     ob_end_clean();
     if (isset($query['-template'])) {
         df_display(array('form' => $out), $query['-template']);
     } else {
         if (isset($action['template'])) {
             df_display(array('form' => $out), $action['template']);
         } else {
             df_display(array('form' => $out), 'Dataface_related_records_checkboxes.html');
         }
     }
 }
Esempio n. 14
0
 function DB_Test($name = 'DB_Test')
 {
     $this->BaseTest($name);
     Dataface_Application::getInstance();
     $this->DB =& Dataface_DB::getInstance();
     //parent::BaseTest();
 }
Esempio n. 15
0
 function handle(&$params)
 {
     try {
         $app =& Dataface_Application::getInstance();
         $query =& $app->getQuery();
         $auth =& Dataface_AuthenticationTool::getInstance();
         $user =& $auth->getLoggedInUser();
         if (!isset($query['-site-id'])) {
             throw new Exception("No site id specified");
         }
         if (isset($query['-compiled'])) {
             if ($query['-compiled'] == 'true' || $query['-compiled'] == 1) {
                 $compiled = 1;
             } else {
                 $compiled = 0;
             }
             $jobs = df_get_records_array('jobs', array('website_id' => $query['-site-id'], 'posted_by' => $user->val('username'), 'compiled' => $compiled));
         } else {
             $jobs = df_get_records_array('jobs', array('website_id' => $query['-site-id'], 'posted_by' => $user->val('username')));
         }
         //array of job ids and job titles to present to user
         $results = array();
         foreach ($jobs as $job) {
             $results[] = array('job_id' => $job->val('job_id'), 'title' => $job->getTitle());
         }
         echo json_encode($results);
     } catch (Exception $e) {
         if ($e->getCode() == E_USER_ERROR) {
             echo $e->getMessage();
         } else {
             throw $e;
         }
     }
 }
Esempio n. 16
0
 function handle2($params)
 {
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $table = $query['-table'];
     if (!@$query['-field']) {
         throw new Exception("No field specified", 500);
     }
     if (!@$query['-key']) {
         throw new Exception("No key specified", 500);
     }
     $tableObj = Dataface_Table::loadTable($table);
     if (PEAR::isError($tableObj)) {
         throw new Exception($tableObj->getMessage(), $tableObj->getCode());
     }
     $field =& $tableObj->getField($query['-field']);
     if (PEAR::isError($field)) {
         throw new Exception("Field not found " . $field->getMessage(), $field->getCode());
     }
     if (!@$field['vocabulary']) {
         throw new Exception("Field has no vocabulary assigned", 500);
     }
     $perms = $tableObj->getPermissions(array('field' => $field['name']));
     if (!@$perms['edit'] && !@$perms['new']) {
         throw new Exception("You don't have permission to access this vocabulary.", 400);
     }
     $valuelist = $tableObj->getValuelist($field['vocabulary']);
     if (PEAR::isError($valuelist)) {
         throw new Exception("Valuelist not found.", 404);
     }
     $value = @$valuelist[$query['-key']];
     df_write_json(array('code' => 200, 'message' => 'Found', 'value' => $value));
 }
Esempio n. 17
0
 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;
         }
     }
 }
Esempio n. 18
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     $context = array();
     if (!$record) {
         return PEAR::raiseError("No record is currently selected", DATAFACE_E_ERROR);
     }
     $history_tablename = $record->_table->tablename . '__history';
     if (!Dataface_Table::tableExists($history_tablename)) {
         $context['error'] = PEAR::raiseError("This record has no history yet recorded.", DATAFACE_E_NOTICE);
     } else {
         import('Dataface/HistoryTool.php');
         $history_tool = new Dataface_HistoryTool();
         $history_log = $history_tool->getHistoryLog($record);
         $context['log'] =& $history_log;
         // let's make a query string for the current record
         //current_record_qstr
         $keys = array_keys($record->_table->keys());
         $qstr = array();
         foreach ($keys as $key) {
             $qstr[] = urlencode('--__keys__[' . $key . ']') . '=' . urlencode($record->strval($key));
         }
         $context['current_record_qstr'] = implode('&', $qstr);
     }
     df_display($context, 'Dataface_RecordHistory.html');
 }
 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;
         }
     }
 }
Esempio n. 20
0
 function loadPreferences($table = null)
 {
     if (!isset($table)) {
         $app =& Dataface_Application::getInstance();
         $query =& $app->getQuery();
         $table = $query['-table'];
     }
     $this->prefs[$table] = array();
     if (class_exists('Dataface_AuthenticationTool')) {
         $auth =& Dataface_AuthenticationTool::getInstance();
         $username = $auth->getLoggedInUsername();
     } else {
         $username = '******';
     }
     $sql = "select * from `dataface__preferences` where `username` in ('*','" . addslashes($username) . "') and `table` in ('*','" . addslashes($table) . "')";
     $res = mysql_query($sql, df_db());
     if (!$res) {
         $this->_createPreferencesTable();
         $res = mysql_query($sql, df_db());
         if (!$res) {
             trigger_error(mysql_error(df_db()), E_USER_ERROR);
         }
     }
     while ($row = mysql_fetch_assoc($res)) {
         if ($row['table'] == '*') {
             $this->prefs['*'][$row['key']] = $row['value'];
         } else {
             $this->prefs[$row['table']][$row['record_id']][$row['key']] = $row['value'];
         }
     }
     @mysql_free_result($res);
     $this->refreshTimes[$table] = time();
 }
Esempio n. 21
0
 function handle($params)
 {
     import('Dataface/SearchForm.php');
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $new = true;
     $form = new Dataface_SearchForm($query['-table'], $app->db(), $query);
     $res = $form->_build();
     if (PEAR::isError($res)) {
         trigger_error($res->toString() . Dataface_Error::printStackTrace(), E_USER_ERROR);
     }
     /*
      *
      * We need to add the current GET parameter flags (the GET vars starting with '-') so
      * that the controller knows to pass control to this method again upon form submission.
      *
      */
     $form->setDefaults(array('-action' => $query['-action']));
     if ($form->validate()) {
         $res = $form->process(array(&$form, 'performFind'));
     }
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('find.js');
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $context = array('form' => &$out);
     df_display($context, 'Dataface_Find_View.html', true);
 }
Esempio n. 22
0
 function handle($params)
 {
     $app = Dataface_Application::getInstance();
     $jt = Dataface_JavascriptTool::getInstance();
     $jt->import('xataface/view/tests/test_MasterDetailView.js');
     df_display(array(), 'xataface/tests/test_MasterDetailView.html');
 }
Esempio n. 23
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     $out = array();
     if (!isset($_POST['--name'])) {
         $out['error'] = 'No name specified';
         $this->respond($out);
         exit;
     }
     if (!isset($_POST['--value'])) {
         $out['error'] = 'No value specified';
         $this->respond($out);
         exit;
     }
     if (isset($_POST['--record_id'])) {
         $recordid = $_POST['--record_id'];
     } else {
         $recordid = $recordd->getId();
     }
     import('Dataface/PreferencesTool.php');
     $pt =& Dataface_PreferencesTool::getInstance();
     $pt->savePreference($recordid, $_POST['--name'], $_POST['--value']);
     $out['message'] = 'Successfully saved preference ' . $_POST['--name'] . ' to ' . $_POST['--value'] . ' for ' . $recordid;
     $this->respond($out);
 }
 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;
         }
     }
 }
Esempio n. 25
0
 function getNavItem($key, $label)
 {
     $query =& Dataface_Application::getInstance()->getQuery();
     if (!isAdmin()) {
         switch ($key) {
             case 'help':
                 return array('href' => DATAFACE_SITE_HREF . '?-action=help', 'label' => $label, 'selected' => $query['-action'] == 'help');
                 // non-admin users can see these
                 throw new Exception("Use default rendering");
         }
         // Non-admin users can't see any other table.
         return null;
     } else {
         //Admin users can see everything..
         switch ($key) {
             case 'help':
                 // reports is not a table so we need to return custom properties.
                 return array('href' => DATAFACE_SITE_HREF . '?-action=help', 'label' => $label, 'selected' => $query['-action'] == 'help');
         }
         // For other actions we need to make sure that they aren't selected
         // if the current action is reports because we want the 'reports'
         // tab to be selected only in that case.
         return array('selected' => $query['-table'] == $key and $query['-action'] != 'help');
     }
 }
Esempio n. 26
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();
 }
Esempio n. 27
0
 public function __construct()
 {
     $type = null;
     if (@$_GET['-xatadoc']) {
         import('modules/XataJax/classes/JavascriptDocumentor.php');
         $type = 'JavascriptDocumentor';
     }
     $js = Dataface_JavascriptTool::getInstance($type);
     $conf = Dataface_Application::getInstance()->_conf;
     $conf = @$conf['Dataface_JavascriptTool'];
     if (!$conf) {
         $conf = array();
     }
     if (@$conf['debug']) {
         $js->setMinify(false);
         $js->setUseCache(false);
     }
     $js->addPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'js', XATAJAX_URL . '/js');
     $js->addPath(DATAFACE_SITE_PATH . DIRECTORY_SEPARATOR . 'js', DATAFACE_SITE_URL . '/js');
     $js->addPath(DATAFACE_PATH . DIRECTORY_SEPARATOR . 'js', DATAFACE_URL . '/js');
     $css = Dataface_CSSTool::getInstance();
     $css->addPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'css', XATAJAX_URL . '/css');
     $css->addPath(DATAFACE_SITE_PATH . DIRECTORY_SEPARATOR . 'css', DATAFACE_SITE_URL . '/css');
     $css->addPath(DATAFACE_PATH . DIRECTORY_SEPARATOR . 'css', DATAFACE_URL . '/css');
 }
Esempio n. 28
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query = $app->getQuery();
     $query['-skip'] = 0;
     $query['-limit'] = 999999999;
     $at = Dataface_ActionTool::getInstance();
     $emailAction = $at->getAction(array('name' => 'email'));
     if (!isset($emailAction) or !isset($emailAction['email_column'])) {
         return PEAR::raiseError("No email column specified");
     }
     $col = $emailAction['email_column'];
     $qb = new Dataface_QueryBuilder($query['-table'], $query);
     $sql = "select `" . $col . "` " . $qb->_from() . $qb->_secure($qb->_where());
     $res = mysql_query($sql, df_db());
     if (!$res) {
         trigger_error(mysql_error(df_db()), E_USER_ERROR);
     }
     $addresses = array();
     while ($row = mysql_fetch_row($res)) {
         $addresses[] = $row[0];
     }
     @mysql_free_result($res);
     header("Content-type: text/plain");
     echo implode(', ', $addresses);
     exit;
 }
 function beforeHandleRequest()
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     if ($query['-table'] == 'dashboard' and ($query['-action'] == 'browse' or $query['-action'] == 'list')) {
         $query['-action'] = 'dashboard';
     }
 }
Esempio n. 30
0
 function init(Dataface_Table $table)
 {
     if (!@Dataface_Application::getInstance()->_conf['enable_static']) {
         $efl =& $table->getField('enable_live_translation');
         $efl['Default'] = 1;
         $efl['widget']['type'] = 'hidden';
     }
 }