Пример #1
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;
         }
     }
 }
Пример #2
0
 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);
 }
Пример #3
0
    function section__notes(&$record)
    {
        $user =& SweteTools::getUser();
        if (isset($user)) {
            require_once 'inc/SweteJobInboxPresentation.php';
            $job = new SweteJob($record);
            $messageList = $job->getInbox($user->val('username'))->getMessageList();
            $jsTool = Dataface_JavascriptTool::getInstance();
            $jsTool->import('swete/tables/jobs/notes.js');
            $content = SweteJobInboxPresentation::tableContent($messageList);
            $inbox = '<table class="job-messages" data-job-id="' . $record->val('job_id') . '" style="width:100%; height:100%">' . $content . '</table>';
            //Add a new message
            $inbox .= '
					<br/><span class="new_note">Add a new note:</span><br/>
					<textarea class="new_note" data-job-id=' . $record->val('job_id') . ' style="width: 100%; height:100px;"  ></textarea>
					<br/><button type="button" class="add_note">Add</button>
				';
            return array('content' => $inbox, 'class' => 'main', 'label' => 'Inbox', 'order' => 0);
        }
    }