Ejemplo n.º 1
0
 public function getUnreadTickets($userId, $limit = 9999)
 {
     $read = new read();
     $unreadTickets = array();
     $count = 0;
     $values = $this->getAllBySearch("", "", 0);
     foreach ($values as $ticket) {
         if (!$read->isRead('ticket', $ticket['id'], $userId) && $count < $limit) {
             $unreadTickets[] = $ticket;
             $count++;
         }
     }
     return $unreadTickets;
 }
Ejemplo n.º 2
0
 case 'newswire':
     require_once PATH_FACEBOOK . '/pages/newswire.class.php';
     $nwObj = new newswire($this);
     $code = $nwObj->fetchNewswirePage($userid, $currentPage);
     break;
 case 'refreshComments':
     if (isset($_GET['cid']) and is_numeric($_GET['cid'])) {
         $cid = $_GET['cid'];
     } else {
         $cid = 0;
         $error = true;
         $errorMsg = 'No story id';
     }
     if (!$error) {
         require_once PATH_CORE . '/classes/read.class.php';
         $comObj = new read($db, $session);
         $code = $comObj->fetchComments($cid);
         $comObj->resetStoryCache($cid);
     } else {
         $code = '<p>There was an error refreshing the comments: ' . $errorMsg . '</p>';
     }
     break;
 case 'postComment':
     $error = false;
     if (isset($_GET['cid']) and is_numeric($_GET['cid'])) {
         $cid = $_GET['cid'];
     } else {
         $cid = 0;
         $error = true;
         $errorMsg = 'No story id';
     }
 function fetch($option = 'comments', $cid = 0)
 {
     // to do - remove, temp for vanishteam
     if (CACHE_PREFIX == 'van' and !$this->session->isAppAuthorized) {
         $fHandle = fopen(PATH_SERVER_LOGS . 'edr.log', 'a');
         fwrite($fHandle, 'Required to authorize:' . $_SERVER['HTTP_X_FB_USER_REMOTE_ADDR'] . "\n");
         $this->facebook = $this->session->app->loadFacebookLibrary();
         $user = $this->facebook->require_login();
     }
     // build the read story page
     require_once PATH_CORE . '/classes/read.class.php';
     $readObj = new read($this->db, $this->session);
     $readObj->setPageLink($this);
     require_once PATH_FACEBOOK . '/classes/actionTeam.class.php';
     $this->teamObj = new actionTeam($this->page);
     if (isset($_GET['cid']) and !is_numeric($_GET['cid'])) {
         $this->page->decloak();
     }
     if ($cid == 0) {
         // need for ajax readStory script
         if (isset($_GET['cid']) and is_numeric($_GET['cid'])) {
             $cid = $_GET['cid'];
         } else {
             exit('error2');
         }
     }
     $referid = $this->page->fetchReferral();
     if ($referid !== false && is_numeric($referid)) {
         // record chat action
         if (isset($_GET['chat'])) {
             if (!$this->session->isAppAuthorized) {
                 // require authorization so we can get their fbId - redirs to signup
                 $this->facebook = $this->session->app->loadFacebookLibrary();
                 $user = $this->facebook->require_login();
             }
             if (isset($_POST['fb_sig_added']) and $_POST['fb_sig_added'] == 1) {
                 $targetfbId = $_POST['fb_sig_user'];
             } else {
                 if (isset($_POST['fb_sig_canvas_user'])) {
                     $targetfbId = $_POST['fb_sig_canvas_user'];
                 } else {
                     $targetfbId = 0;
                 }
             }
             // make sure the referer is not clicking on the link themselves
             if ($targetfbId != 0 and $referid != $this->session->userid) {
                 // log referid as having referred this user
                 require_once PATH_CORE . '/classes/log.class.php';
                 $logObj = new log($this->db);
                 $logItem = $logObj->serialize(0, $referid, 'chatStory', $cid, $targetfbId);
                 $inLog = $logObj->update($logItem);
             }
         }
         // check for notification and display it
         if ($this->session->isLoaded and $referid != $this->session->userid) {
             // reader was referred here by someone
             require_once PATH_CORE . '/classes/notifications.class.php';
             $notificationsTable = new NotificationsTable($this->db);
             $msgid = $notificationsTable->lookupReferral($referid, $cid, $this->session->fbId);
             if ($msgid !== false and $msgid != '' and !is_null($msgid)) {
                 $notificationsTable->setStatus($msgid, $this->session->fbId, 'opened');
                 // get fbId from userid
                 require_once PATH_CORE . '/classes/user.class.php';
                 $uit = new UserInfoTable($this->db);
                 $ui = $uit->getRowObject();
                 $ui->load($referid);
                 $msgTable = new NotificationMessagesTable($this->db);
                 $msg = $msgTable->getRowObject();
                 // load the message
                 $msg->load($msgid);
                 // cast msg object into comment property array for token replacement
                 $referObj = array();
                 $referObj[fbId] = $ui->fbId;
                 $referObj[userid] = $referid;
                 $referObj[comments] = $msg->message;
                 $referObj[date] = $msg->dateCreated;
                 $referMsg = $readObj->fetchReferComment($referObj);
             }
         }
         $this->page->recordReferral($referid, 'referReader', $cid);
     }
     if (isset($_GET['viaBookmarklet'])) {
         //$inside.='<script type="text/javascript">function closeWindow() {window.opener = self;window.close();}</script><a href="#" onclick="closeWindow();">test</a>';
         //$inside.=$this->page->buildMessage('success','Your story has been posted','Click here if you wish to <a href="#" onclick="closeWindow();">close this window</a>.');
     } else {
         if (isset($_GET['justPosted'])) {
             // to do: put some options here
         }
     }
     $inside .= '<div id="col_left"><!-- begin left side -->';
     $inside .= $referMsg;
     $inside .= $readObj->fetchReadStory($cid, $option);
     $inside .= '</div><!-- end left side -->';
     $inside .= '<div id="col_right">';
     if ($this->session->isAdmin) {
         $inside .= '<div class="panel_1"><div class="panelBar clearfix">';
         $inside .= '<h2>Administrative Options</h2>';
         $inside .= '</div><!-- end panelBar -->';
         $inside .= '<div class="panel_block">';
         $inside .= '<ul><li><span id="banStoryPoster"><a href="#" onclick="banStoryPoster(' . $cid . ');return false;">Ban Member</a></span></li></ul>';
         // <span id="blockStory"><a href="#" onclick="blockStory('.$cid.');return false;">Block story</a></span><span class="pipe">|</span>
         $inside .= '</div><!-- end panel_block --></div><!-- end panel_1 -->';
     }
     $inside .= $readObj->fetchReadSidePanel($cid, $this->session, $this->page->isAjax);
     if (defined('ADS_ANY_SIDEBAR_BOTTOM')) {
         $inside .= str_replace("{ad}", '<fb:iframe src="' . URL_CALLBACK . '?p=cache&m=ad&locale=anySidebarBottom" frameborder="0" scrolling="no" style="width:180px;height:600px;padding:0px;margin:-5px 0px 0px 0px;"/>', $this->common['adWrapTallSidebar']);
     }
     $inside .= '</div> <!-- end right side -->';
     if ($this->page->isAjax) {
         return $inside;
     }
     $code .= '<input type="hidden" id="filter" value="default">';
     $code .= $this->page->constructPage('read', $inside);
     return $code;
 }
Ejemplo n.º 4
0
  */
 // CARREGANDO COLUNAS DA TABELA ONMT_USUÁRIO
 /* QUERY NO MYSQL
  * "SELECT `nome`, `email`, `celular` FROM `onmt_usuario`";
  */
 /* Decodificando a string Json:
  * Foi feito assim pois se o for recebido como array/object vem em ordem
  * alfabética, o que é ruim. */
 $colunas = json_decode($colunas, TRUE);
 if (count($colunas) > 0) {
     /**
      * @var $colunaQString : Geração da Qeury String para consulta.
      */
     $colunaQString = "`" . implode("`, `", array_keys($colunas)) . "`";
     //echo $colunaQString;
     $nCT = new read();
     $nCT->ExeReadColumn($tabela, $colunaQString);
     $result = $nCT->getResult();
     print_r(json_encode($result));
 } else {
     echo "<b>Erro na variável \$Colunas:</b> @ Esta variável deve ser<br>" . " passada como array (json) contendo o nome das colunas que devem<br>" . ' ser obitidas na busca ao BD.<br><b> Ex.:</b> headers: {nome: "Nome", email:"E-mail", celular:"Celular"}<p><p>';
 }
 //        $nCT = new read;
 //
 //        //$Query = "SELECT {$colunaQString} FROM `onmt_usuario`";
 //        //$nCT->FullRead($Query);
 //        $nCT->ExeReadColumn($tabela, $colunaQString);
 //        $result = $nCT->getResult();
 //
 //        //$r = serialize($result);print_r("<pre>".$r."</pre>");
 //        //var_dump($result);
Ejemplo n.º 5
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $msgKey = '';
     if (isset($_GET['id']) === true) {
         $id = (int) $_GET['id'];
         $ticket = $this->getTicket($id);
         $editable = true;
         if (!empty($ticket)) {
             $helper = new helper();
             $file = new files();
             $user = new users();
             $comment = new comments();
             // Has the user seen this ticket already
             $read = new read();
             if (!$read->isRead('ticket', $id, $_SESSION['userdata']['id'])) {
                 $read->markAsRead('ticket', $id, $_SESSION['userdata']['id']);
             }
             //TODO New access right management...This is dumb
             if ($ticket['userId'] == $_SESSION['userdata']['id'] || $ticket['editorId'] == $_SESSION['userdata']['id'] || $ticket['editorId'] == '') {
                 $editable = true;
             }
             //Punch times
             if (isset($_POST['punchIn']) && $this->isClocked($_SESSION['userdata']['id']) != true) {
                 $this->punchIn($ticket['id']);
             } else {
                 if (isset($_POST['punchOut']) && $this->isClocked($_SESSION['userdata']['id']) == true) {
                     $this->punchOut($ticket['id']);
                 }
             }
             //Upload File
             if (isset($_POST['upload'])) {
                 if (isset($_FILES['file'])) {
                     if ($file->upload($_FILES, 'ticket', $id) !== false) {
                         $tpl->setNotification('FILE_UPLOADED', 'success');
                     } else {
                         $tpl->setNotification('ERROR_WHILE_UPLOADING', 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_FILE', 'error');
                 }
             }
             //Add comment
             if (isset($_POST['comment']) === true) {
                 $mail = new mailer();
                 $values = array('text' => $_POST['text'], 'date' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']);
                 $comment->addComment($values, 'ticket');
                 $tpl->setNotification('COMMENT_ADDED', 'success');
             }
             //Only admins
             if ($_SESSION['userdata']['role'] == 'admin') {
                 $editable = true;
                 //Delete file
                 if (isset($_GET['delFile']) === true) {
                     $file = $_GET['delFile'];
                     $upload = new fileupload();
                     $upload->initFile($file);
                     //Delete file from server
                     $upload->deleteFile($file);
                     //Delete file from db
                     $this->deleteFile($file);
                     $msgKey = 'FILE_DELETED';
                 }
                 //Delete comment
                 if (isset($_GET['delComment']) === true) {
                     $commentId = (int) $_GET['delComment'];
                     $comment->deleteComment($commentId);
                     $msgKey = 'COMMENT_DELETED';
                 }
             }
             $allHours = 0;
             $values = array('userId' => $_SESSION['userdata']['id'], 'ticket' => $id, 'date' => '', 'kind' => '', 'hours' => '', 'description' => '', 'invoicedEmpl' => '', 'invoicedComp' => '', 'invoicedEmplDate' => '', 'invoicedCompDate' => '');
             $timesheets = new timesheets();
             $ticketHours = $timesheets->getTicketHours($id);
             $tpl->assign('ticketHours', $ticketHours);
             $tpl->assign('userHours', $timesheets->getUsersTicketHours($id, $_SESSION['userdata']['id']));
             $userinfo = $user->getUser($values['userId']);
             $tpl->assign('kind', $timesheets->kind);
             $tpl->assign('userInfo', $userinfo);
             if (isset($_POST['saveTimes']) === true) {
                 if (isset($_POST['kind']) && $_POST['kind'] != '') {
                     $values['kind'] = $_POST['kind'];
                 }
                 if (isset($_POST['date']) && $_POST['date'] != '') {
                     $date = $helper->date2timestamp($_POST['date']);
                     //die($date);
                     //$values['date'] = ($helper->timestamp2date($date, 4));
                     $values['date'] = $date;
                 }
                 $values['rate'] = $userinfo['wage'];
                 if (isset($_POST['hours']) && $_POST['hours'] != '') {
                     $values['hours'] = $_POST['hours'];
                 }
                 if (isset($_POST['description']) && $_POST['description'] != '') {
                     $values['description'] = $_POST['description'];
                 }
                 if ($values['kind'] != '') {
                     if ($values['date'] != '') {
                         if ($values['hours'] != '' && $values['hours'] > 0) {
                             $timesheets->addTime($values);
                             $tpl->setNotification('TIME_SAVED', 'success');
                         } else {
                             $tpl->setNotification('NO_HOURS', 'success');
                         }
                     } else {
                         $tpl->setNotification('NO_DATE', 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_KIND', 'success');
                 }
                 $tpl->assign('userId', $values['userId']);
             }
             $timesheets = new timesheets();
             $language = new language();
             $language->setModule('tickets');
             $lang = $language->readIni();
             $data = array();
             $data2 = array();
             $months = array();
             $results = $timesheets->getTicketHours($id);
             $allHours = 0;
             foreach ($results as $row) {
                 if ($row['summe']) {
                     $allHours += $row['summe'];
                 }
             }
             $tpl->assign('timesheetsAllHours', $allHours);
             $remainingHours = $ticket['planHours'] - $allHours;
             $comments = $comment->getComments('ticket', $ticket['id']);
             $files = $file->getFilesByModule('ticket', $id);
             $unreadCount = count($this->getUnreadTickets($_SESSION['userdata']['id']));
             $tpl->assign('unreadCount', $unreadCount);
             $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'));
             $tpl->assign('ticketHistory', $this->getTicketHistory((int) $_GET['id']));
             $tpl->assign('remainingHours', $remainingHours);
             $tpl->assign('ticketPrice', $this->getTicketCost($_GET['id']));
             $tpl->assign('info', $msgKey);
             $tpl->assign('role', $_SESSION['userdata']['role']);
             $tpl->assign('ticket', $ticket);
             $tpl->assign('objTicket', $this);
             $tpl->assign('state', $this->state);
             $tpl->assign('statePlain', $this->statePlain);
             $tpl->assign('numComments', $comment->countComments('ticket', $ticket['id']));
             $tpl->assign('comments', $comments);
             $tpl->assign('editable', $editable);
             $tpl->assign('files', $files);
             $tpl->assign('numFiles', count($files));
             $tpl->assign('helper', $helper);
             $tpl->display('tickets.showTicket');
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }