Пример #1
0
    /**
     * Updates a particular model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id the ID of the model to be updated
     */
    public function actionUpdate($id)
    {
        $model = $this->loadModel($id);
        $messageModels = LanguageModel::model()->getAllLanguageModels($id);

        if (isset($_POST['SourceMessageModel'])) {
            $model->attributes = $_POST['SourceMessageModel'];
            if ($_POST['MessageModel']) {
                foreach ($_POST['MessageModel'] as $key => $value) {
                    if (!empty($value['translation'])) {
                        $messageModel = MessageModel::model()->findByAttributes(array('id' => $model->id, 'language' => $key));
                        if ($messageModel == null) {
                            $messageModel = new MessageModel;
                            $messageModel->language = $key;
                            $messageModel->id = $model->id;
                            $messageModel->setIsNewRecord(true);
                        } else {
                            $messageModel->setIsNewRecord(false);
                        }
                       // die($messageModel->isNewRecord);
                        $messageModel->attributes = $value;
                        $messageModel->save(false);
                    }
                }
            }
            if ($model->save())
                $this->redirect(array('index'));
        }

        $this->render('update', array(
            'model' => $model,
            'messageModels' => $messageModels,
        ));
    }
Пример #2
0
 /**
  * 处理已读消息
  */
 public function setReadAction()
 {
     echo date('Y-m-d H:i:s') . ' setRead is started!' . PHP_EOL;
     $queueKey = Yaf\Application::app()->getConfig()->redisKeys->setReadQueue;
     $readKeyPrefix = Yaf\Application::app()->getConfig()->redisKeys->readKeyPrefix;
     $redis = RedisFactory::instance('ims', true);
     while (true) {
         while ($userId = $redis->lPop($queueKey)) {
             $key = $readKeyPrefix . '_' . $userId;
             while ($messageId = $redis->lpop($key)) {
                 $messageModel = new MessageModel($userId);
                 $messageModel->setIsRead($messageId);
             }
             //推送未读消息变动通知
             $userModel = new UserModel();
             pushModel::unreadMessageNotice($userModel->getUnreadMessageList(true));
         }
         try {
             // 闲置时检查Redis连接
             $redis->ping();
         } catch (\Exception $e) {
             $redis = RedisFactory::instance('ims', true, true);
             //重连
         }
         sleep(1);
     }
     exit;
 }
Пример #3
0
 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         // echo 'test'.$PreviewThemeFolder;
         if ($PreviewThemeFolder != '') {
             $Sender->Theme = $PreviewThemeFolder;
             $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
             $Sender->AddCssFile('previewtheme.css');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     if ($Sender->MasterView != 'empty' && in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location);
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             $Sender->AddModule($MessageModule);
         }
     }
 }
Пример #4
0
 /**
  * 发送消息
  * @return boolean
  */
 public function sendAction()
 {
     $messageModel = new MessageModel($this->userInfo['userId']);
     $result = $messageModel->save($this->requestParams);
     if ($messageModel->getErrCode()) {
         $this->putError($messageModel->getErrCode(), $messageModel->getErrInfo());
         return false;
     }
     $this->response($result);
     return false;
 }
Пример #5
0
 public function saveAction()
 {
     $message = array();
     $message['catId'] = 1;
     $message['sender'] = 10;
     $message['senderNickname'] = 'sender_10';
     $message['receiver'] = 12;
     $message['receiverNickname'] = 'receiver_12';
     $message['content'] = 'content_' . date('YmdHis');
     $messageModel = new MessageModel();
     $respones = array();
     $respones['result'] = $messageModel->save($message);
     $respones['errCode'] = $messageModel->getErrCode();
     $respones['errInfo'] = $messageModel->getErrInfo();
     $this->getResponse()->setBody(json_encode($respones));
 }
Пример #6
0
 public function getSchool()
 {
     $url = Common_Config::SSO_ENTRY_URL;
     $array = [];
     $index = 0;
     $rows = 20;
     $cl = new Common_Curl();
     for ($page = 1; $index == 0 || $index > 0 && array_key_exists($index, $array); $page++) {
         $post_data = array("page" => $page, "rows" => $rows);
         //print_r($post_data);
         $array = array_merge($array, $cl->request($url, $post_data));
         //print_r($entry);
         $index = $page * $rows - 1;
     }
     //判断是否返回失败信息
     if (empty($array)) {
         return -1;
     }
     $new_array = [];
     $index = 0;
     //print_r($new_array);
     $messageModel = new MessageModel();
     $schoolIds = $messageModel->getSchoolId();
     $schoolId = $schoolIds['schoolId'];
     foreach ($array as $k => $val) {
         if (is_array($val) && $val['id'] > $schoolId) {
             $new_array[$index] = $val;
             $index++;
             $messageModel->updateSchoolId($schoolIds['id'], $val['id']);
         }
     }
     //首次启动,不进行提示
     $update_time = $messageModel->getSchoolTime();
     $messageModel->updateGetSchoolTime();
     if (!$update_time) {
         return -3;
     }
     //print_r($new_array);
     //没有新更新的频道
     if ($new_array == []) {
         return -2;
     }
     return $new_array;
 }
 public function send()
 {
     $name = isset($_POST['name']) ? trim($_POST['name']) : '';
     $email = isset($_POST['email']) ? trim($_POST['email']) : '';
     $content = isset($_POST['content']) ? trim($_POST['content']) : '';
     // 过滤
     $name = htmlspecialchars($name, ENT_QUOTES);
     $email = htmlspecialchars($email, ENT_QUOTES);
     $content = htmlspecialchars($content, ENT_QUOTES);
     if (empty($name) || empty($email) || empty($content)) {
         $this->error('index.php?c=public&a=message', '留言失败,不允许出现空内容...');
     }
     $message = new MessageModel();
     if ($message->insertMessage($name, $email, $content)) {
         $this->success('index.php?c=public&a=message', '留言成功!');
     } else {
         $this->error('index.php?c=public&a=message', '留言失败...');
     }
 }
Пример #8
0
 public function sendAction()
 {
     $params = $this->getRequest()->getParams();
     $toKen = $params['toKen'];
     $userModel = new UserModel();
     $userInfo = $userModel->getUserInfoByToken($toKen);
     $message = array();
     $message['catId'] = 1;
     $message['sender'] = $userInfo['userId'];
     $message['senderNickname'] = $userInfo['nickname'];
     $message['receiver'] = 12;
     $message['receiverNickname'] = 'receiver_12';
     $message['content'] = 'content_' . date('YmdHis');
     $messageModel = new MessageModel();
     $respones = array();
     $respones['result'] = $messageModel->save($message);
     $respones['errCode'] = $messageModel->getErrCode();
     $respones['errInfo'] = $messageModel->getErrInfo();
     $this->getResponse()->setBody(json_encode($respones));
 }
Пример #9
0
 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         // echo 'test'.$PreviewThemeFolder;
         if ($PreviewThemeFolder != '') {
             $Sender->Theme = $PreviewThemeFolder;
             $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
             $Sender->AddCssFile('previewtheme.css');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if ($Sender->MasterView == 'admin') {
         $Exceptions[] = '[Admin]';
     } else {
         if (in_array($Sender->MasterView, array('', 'default'))) {
             $Exceptions[] = '[NonAdmin]';
         }
     }
     if ($Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache)) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             $Sender->AddModule($MessageModule);
         }
     }
     // If there are applicants, alert admins by showing in the main menu
     if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') {
         $CountApplicants = Gdn::UserModel()->GetApplicants()->NumRows();
         if ($CountApplicants > 0) {
             $Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span>' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Registration.Manage'));
         }
     }
 }
Пример #10
0
 /**
  * 将消息和用户关联
  * @param  MessageModel $p_msgModel   消息模型
  * @param  array  $p_queryWhere   用户的筛选方案
  * @return int                   关联个数
  */
 public static function createNewModels($p_msgModel, $p_queryWhere = array())
 {
     $userIDs = DBModel::instance('user')->where($p_queryWhere)->selectValues('id');
     $tmpData = array();
     $tmpData['msgID'] = $p_msgModel->getId();
     $tmpData['readStatus'] = READ_STATUS::UNREAD;
     $tmpData['createTime'] = date('Y-m-d H:i:s');
     $tmpData['modifyTime'] = date('Y-m-d H:i:s');
     $dbFac = static::newDBModel();
     foreach ($userIDs as $userID) {
         $tmpData['userID'] = $userID;
         $dbFac->insert($tmpData);
     }
     //推送
     if (count($userIDs) > 0) {
         $p_where = array();
         $p_where['joinList'] = array();
         $p_where['joinList'][] = array('relationMessageUser t2', array('t2.userID = t1.userID', 't2.msgID' => $p_msgID, 't2.readStatus' => READ_STATUS::UNREAD));
         DeviceController::pushSingleMessage($p_where, $p_msgModel->getTitle(), $p_msgModel->getDescription(), $customtype = null, $customvalue = null, $tag_name = null);
     }
     return count($userIDs);
 }
Пример #11
0
 public function validateDb()
 {
     $errors = array('message' => 'Database structure is invalid');
     try {
         $db = $this->get('db');
         // Reconnect in case the database was created just now
         $db->reconnect();
         $tables = $db->getTables();
         $expectedTables = array(UserModel::repo()->getTableName(), MessageModel::repo()->getTableName(), DataModel::repo('')->getTableName());
     } catch (Exception $ex) {
         $errors['message'] = 'Database exception: ' . $ex->getMessage();
         return $errors;
     }
     if (count(array_diff($expectedTables, $tables)) !== 0) {
         $errors['message'] = 'Invalid table structure, actual tables: ' . join(', ', $tables) . ', expected tables: ' . join(', ', $expectedTables);
         return $errors;
     }
     return array();
 }
Пример #12
0
 public function getNoticeAction()
 {
     //      Load cac model can thiet
     Zend_Loader::loadClass('MessageModel');
     Zend_Loader::loadClass('AdvertiseModel');
     $params = $this->_arrParam;
     try {
         // Kiem tra hop qua tang xem co tin nhan ko?
         $message_model = new MessageModel();
         $list_message = $message_model->getList(null);
         $content = array();
         $message = array();
         $count_message = count($list_message);
         if (!empty($list_message) && $count_message) {
             foreach ($list_message as $item) {
                 $message[] = array("message_content" => $item['message'], "message_eng" => $item["message_eng"]);
             }
         }
         $content["message"] = $message;
         $advertise_model = new AdvertiseModel();
         $list_advertise = $advertise_model->getList();
         $advertise = array();
         if (!empty($list_advertise) && count($list_advertise)) {
             foreach ($list_advertise as $item) {
                 $advertise[] = array("icon" => $item['icon'], "link" => $item["link"], "message_vn" => $item["message_vn"], "message_eng" => $item["message_eng"]);
             }
         }
         $content['advertise'] = $advertise;
         $data = array("code" => 1, "content" => $content);
     } catch (exception $e) {
         $data = array("code" => 0, "content" => "Error in server");
     }
     echo json_encode($data);
     exit;
 }
<?php

session_start();
//这是一个控制器,专门处理对信息分页查询
//echo "ok";
require_once 'smarty_inc.php';
require_once '../model/messageModel.class.php';
require_once '../model/mypage.class.php';
require_once '../sqlHelper.class.php';
if (isset($_GET['page'])) {
    $page = $_GET['page'];
}
//获取总记录
$mysqli = new SqlHelper();
$sql = "select count(*) from message where getter = '" . $_SESSION['loginname'] . "'";
$mypage = new Mypage($page, 7, 5, $mysqli->pagingCount($sql));
$mypage->goToURL = 'messageListUIController.php';
$messageModel = new MessageModel();
$smarty->assign('res', $messageModel->showMessageByPage($mypage, $_SESSION['loginname']));
$smarty->assign('page_banne', $mypage->navigationBar());
$smarty->display("messageList.tpl");
Пример #14
0
 function newReadQuiz($quizNumber, $m, $quizArray)
 {
     switch ($quizNumber) {
         case 6:
             $this->clientAction = 2;
             require_once MODEL_PATH . 'msg.php';
             $mm = new MessageModel();
             $messageId = $mm->sendMessage(1, $this->appConfig['system']['adminName'], $this->player->playerId, $this->data['name'], guide_task_msg_subject, guide_task_msg_body);
             $quizArray[] = $messageId;
             $m->setGuideTask($this->player->playerId, implode(',', $quizArray));
             break;
         case 7:
             $map_size = $this->setupMetadata['map_size'];
             $_x = $this->data['rel_x'];
             $_y = $this->data['rel_y'];
             $mapMatrix = implode(',', $this->__getVillageMatrix($map_size, $_x, $_y, 3));
             $reader = $m->getVillagesMatrix($mapMatrix);
             $availableVillages = array();
             while ($reader->next()) {
                 if (!$reader->row['is_oasis'] && 0 < intval($reader->row['player_id']) && intval($reader->row['player_id']) != $this->player->playerId) {
                     $availableVillages[] = array($reader->row['rel_x'], $reader->row['rel_y'], $reader->row['village_name']);
                     continue;
                 }
             }
             if (sizeof($availableVillages) == 0) {
                 $availableVillages[] = array($this->data['rel_x'], $this->data['rel_y'], $this->data['village_name']);
             }
             $r_indx = mt_rand(0, sizeof($availableVillages) - 1);
             $this->guideData['vname'] = $availableVillages[$r_indx][2];
             $quizArray[] = implode('|', $availableVillages[$r_indx]);
             $m->setGuideTask($this->player->playerId, implode(',', $quizArray));
             break;
         case 20:
         case 21:
             $this->taskState = $quizArray[sizeof($quizArray) - 1] == 1 ? 2 : 0;
             $this->guideData['troop_id'] = $this->getFirstTroopId($this->data['tribe_id']);
             $this->guideData['troop_name'] = constant('troop_' . $this->guideData['troop_id']);
     }
 }
 /**
  * 删除留言
  * By:0x584A
  * Date:2015年9月23日 12:56:39
  */
 public function delmessage()
 {
     // 接收删除ID
     $bid = intval($_REQUEST['bid']);
     //判断删除的留言是否存在
     $message = new MessageModel();
     $talk = $message->getById($bid);
     if ($talk) {
         $message->deleteByID($bid);
         $logs = new LogsModel();
         $logs->insertOne($_SESSION['adminuser']['u_name'] . "删除留言【" . $talk['m_name'] . "】成功");
         $this->success('index.php?c=index&a=listmessage', '删除成功..');
     } else {
         $logs = new LogsModel();
         $logs->insertOne($_SESSION['adminuser']['u_name'] . "删除留言【" . $talk['m_name'] . "】<font style='color:red'>失败</font>");
         $this->error("index.php?c=index&a=listmessage", '删除失败,请联系管理员..');
     }
 }
Пример #16
0
 /**
  * Fire before every page render.
  *
  * @param Gdn_Controller $Sender
  */
 public function base_render_before($Sender)
 {
     $Session = Gdn::session();
     if ($Sender->MasterView == 'admin') {
         if (val('Form', $Sender)) {
             $Sender->Form->setStyles('bootstrap');
         }
         $Sender->CssClass = htmlspecialchars($Sender->CssClass);
         $Sections = Gdn_Theme::section(null, 'get');
         if (is_array($Sections)) {
             foreach ($Sections as $Section) {
                 $Sender->CssClass .= ' Section-' . $Section;
             }
         }
         // Get our plugin nav items.
         $navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav());
         $Sender->EventArguments['SideMenu'] = $navAdapter;
         $Sender->fireEvent('GetAppSettingsMenuItems');
         $Sender->removeJsFile('jquery.popup.js');
         $Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard');
         $Sender->addJsFile('dashboard.js', 'dashboard');
         $Sender->addJsFile('jquery.expander.js');
         $Sender->addJsFile('settings.js', 'dashboard');
         $Sender->addJsFile('vendors/tether.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard');
         $Sender->addJsFile('vendors/drop.min.js', 'dashboard');
         $Sender->addJsFile('vendors/moment.min.js', 'dashboard');
         $Sender->addJsFile('vendors/daterangepicker.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard');
         $Sender->addJsFile('vendors/clipboard.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard');
         $Sender->addJsFile('vendors/icheck.min.js', 'dashboard');
         $Sender->addJsFile('jquery.tablejenga.js', 'dashboard');
         $Sender->addJsFile('jquery.fluidfixed.js', 'dashboard');
         $Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ace.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard');
         $Sender->addCssFile('vendors/tomorrow.css', 'dashboard');
     }
     // Check the statistics.
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         Gdn::statistics()->check();
     }
     // Inform user of theme previewing
     if ($Session->isValid()) {
         $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
         $PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', ''));
         $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder));
         $PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder));
         if ($PreviewThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
         if ($PreviewMobileThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->isValid()) {
         $Confirmed = val('Confirmed', Gdn::session()->User, true);
         if (UserModel::requireConfirmEmail() && !$Confirmed) {
             $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->informMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->addModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::factory('Statistics');
         $Gdn_Statistics->check($Sender);
     }
     // Allow forum embedding
     if ($Embed = c('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = c('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->addDefinition('RemoteUrl', $RemoteUrl);
         }
         if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
             $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
         }
         // Force embedding?
         if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
             if (IsMobile()) {
                 $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
             } else {
                 $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
             }
             $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
             $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->addDefinition('Path', Gdn::request()->path());
         $get = Gdn::request()->get();
         unset($get['p']);
         // kludge for old index.php?p=/path
         $Sender->addDefinition('Query', http_build_query($get));
         // $Sender->addDefinition('MasterView', $Sender->MasterView);
         $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->addJsFile('vanilla.embed.local.js');
         } else {
             $Sender->addJsFile('embed_local.js');
         }
     } else {
         $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = val('X-UA-Device-Force', $_COOKIE);
     if ($ForceNoMobile === 'desktop') {
         $Sender->addAsset('Foot', wrap(Anchor(t('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
     // Allow global translation of TagHint
     $Sender->addDefinition("TagHint", t("TagHint", "Start to type..."));
     // Add symbols.
     if ($Sender->deliveryMethod() === DELIVERY_METHOD_XHTML) {
         $Sender->addAsset('Symbols', $Sender->fetchView('symbols', '', 'Dashboard'));
     }
 }
Пример #17
0
 public function screen_detail_message()
 {
     $message_id = "";
     if (isset($_GET['message_id'])) {
         $message_id = $_GET['message_id'];
     }
     $this->title = "メッセージ確認";
     $this->message = "";
     $this->file = "system_detail_message.tpl";
     $MessageModel = new MessageModel();
     $message_data = $MessageModel->system_get_detail_message_messsage_id($message_id);
     $this->view->assign('data', $message_data);
     $this->view_display();
 }
   public function UpdateResponse() {
      // Get the message, response, and transientkey
      $Messages = TrueStripSlashes(GetValue('Messages', $_POST));
      $Response = TrueStripSlashes(GetValue('Response', $_POST));
      $TransientKey = GetIncomingValue('TransientKey', '');
      
      // If the key validates
      $Session = Gdn::Session();
      if ($Session->ValidateTransientKey($TransientKey)) {
         // If messages wasn't empty
         if ($Messages != '') {
            // Unserialize them & save them if necessary
            $Messages = Gdn_Format::Unserialize($Messages);
            if (is_array($Messages)) {
               $MessageModel = new MessageModel();
               foreach ($Messages as $Message) {
                  // Check to see if it already exists, and if not, add it.
                  if (is_object($Message))
                     $Message = Gdn_Format::ObjectAsArray($Message);

                  $Content = ArrayValue('Content', $Message, '');
                  if ($Content != '') {
                     $Data = $MessageModel->GetWhere(array('Content' => $Content));
                     if ($Data->NumRows() == 0) {
                        $MessageModel->Save(array(
                           'Content' => $Content,
                           'AllowDismiss' => ArrayValue('AllowDismiss', $Message, '1'),
                           'Enabled' => ArrayValue('Enabled', $Message, '1'),
                           'Application' => ArrayValue('Application', $Message, 'Dashboard'),
                           'Controller' => ArrayValue('Controller', $Message, 'Settings'),
                           'Method' => ArrayValue('Method', $Message, ''),
                           'AssetTarget' => ArrayValue('AssetTarget', $Message, 'Content'),
                           'CssClass' => ArrayValue('CssClass', $Message, '')
                        ));
                     }
                  }
               }
            }
         }

         // Save some info to the configuration file
         $Save = array();

         // If the response wasn't empty, save it in the config
         if ($Response != '')
            $Save['Garden.RequiredUpdates'] = Gdn_Format::Unserialize($Response);
      
         // Record the current update check time in the config.
         $Save['Garden.UpdateCheckDate'] = time();
         SaveToConfig($Save);
      }
   }
Пример #19
0
 public function screen_reply_message()
 {
     $message_id = "";
     $btn1 = "";
     $btn2 = "";
     $reset = "";
     if (isset($_POST['message_id'])) {
         $_SESSION['message_id'] = $_POST['message_id'];
     }
     $this->make_message_form();
     if ($this->action == "form") {
         $MessageModel = new MessageModel();
         $message_data = $MessageModel->get_message_message_id($_SESSION['message_id']);
         $subject = "Re:" . $message_data['subject'];
         $body = "\n----------<" . $message_data['reg_date'] . ">----------\n";
         $body .= $message_data['body'];
         $body = str_replace('<br />', "", $body);
         $body = str_replace("\n", "\n" . '>', $body);
         $body = "\n\n\n" . $body;
         $this->form->setDefaults(array('subject' => $subject, 'body' => $body));
         $this->title = "返信画面";
         $this->next_type = "reply_message";
         $this->next_action = "confirm";
         $this->file = "reply_message.tpl";
         $btn1 = "確認";
     } else {
         if ($this->action == "confirm" && isset($_POST['submit1']) && $_POST['submit1'] == "確認") {
             $this->form->freeze();
             $this->title = "返信画面";
             $this->message = "<font color='red'>下記をお送りしても宜しいでしょうか?</font>";
             $this->next_type = "reply_message";
             $this->next_action = "complete";
             $this->file = "reply_message.tpl";
             $btn1 = "OK";
             $btn2 = "戻る";
         } else {
             if ($this->action == "complete" && isset($_POST['submit2']) && $_POST['submit2'] == "戻る") {
                 $this->title = "返信画面";
                 $this->next_type = "reply_message";
                 $this->next_action = "confirm";
                 $this->file = "reply_message.tpl";
                 $btn1 = "確認";
             } else {
                 if ($this->action == "complete" && isset($_POST['submit1']) && $_POST['submit1'] == "OK") {
                     $this->title = "送信完了";
                     $this->message = "メッセージの送信が完了しました";
                     $data = $this->form->getSubmitValues();
                     $MessageModel = new MessageModel();
                     $message_data = $MessageModel->get_message_message_id($_SESSION['message_id']);
                     //返信済みとmessageに記録
                     $MessageModel->modify_message_re_message_id($_SESSION['message_id']);
                     //DBの文字制限  subject:100文字/body:1250文字までの容量
                     $message_data['subject'] = mb_strimwidth($data['subject'], 0, 100 * 2);
                     $message_data['body'] = mb_strimwidth($data['body'], 0, 1000 * 2);
                     //DBへの登録
                     $MessageModel->regist_member_message($message_data);
                     $this->file = "message.tpl";
                     unset($_SESSION['message_id']);
                 }
             }
         }
     }
     $this->form->addElement('submit', 'submit1', $btn1);
     $this->form->addElement('submit', 'submit2', $btn2);
     $this->form->addElement('reset', 'reset', $reset);
     $this->view_display();
 }
 /**
  * [留言管理列表]
  */
 public function listmessage()
 {
     $message = new MessageModel();
     // 当前页码
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     // 每页显示数量
     $counts = $GLOBALS['config']['admin_goods_pagecount'];
     //计算分页次数
     $pagecount = $message->getAddNum();
     // 总记录数
     $pages = ceil($pagecount / $counts);
     // 字符过滤
     if (!is_integer($page) || $page < 1 || $page > $pages) {
         $page = 1;
     }
     // 分页显示数据
     $tables = $message->getAllLogs($page, $counts);
     // 分页字符串
     $pagestr = Page::setAHtmlPage('index.php', 'index', 'listartice', $pagecount, $counts, $page);
     include_once VIEW_DIR . '/message_list.html';
 }
Пример #21
0
    function load()
    {
        parent::load();
        $this->sendMail = TRUE;
        $this->isInbox = TRUE;
        $this->viewOnly = FALSE;
        $this->showFriendPane = FALSE;
        $this->errorText = '';
        $this->showList = !(isset($_GET['t']) && is_numeric($_GET['t']) && intval($_GET['t']) == 1);
        $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 2 ? intval($_GET['t']) : 0;
        $this->friendList = array();
        $friends_player_ids = trim($this->data['friend_players']);
        if ($friends_player_ids != '') {
            $friends_player_ids = explode('
', $friends_player_ids);
            foreach ($friends_player_ids as $friend) {
                list($playerId, $playerName) = explode(' ', $friend);
                $this->friendList[$playerId] = $playerName;
            }
        }
        $m = new MessageModel();
        if (!$this->isPost()) {
            if (isset($_GET['uid']) && is_numeric($_GET['uid']) && 0 < intval($_GET['uid'])) {
                $this->receiver = $m->getPlayerNameById(intval($_GET['uid']));
                $this->showList = FALSE;
                $this->selectedTabIndex = 1;
            } else {
                if (isset($_GET['id']) && is_numeric($_GET['id']) && 0 < intval($_GET['id'])) {
                    $result = $m->getMessage($this->player->playerId, intval($_GET['id']));
                    if ($result->next()) {
                        $this->viewOnly = TRUE;
                        $this->showList = FALSE;
                        $this->isInbox = $result->row['to_player_id'] == $this->player->playerId;
                        $this->sendMail = !$this->isInbox;
                        $this->receiver = $this->isInbox ? $result->row['from_player_name'] : $result->row['to_player_name'];
                        $this->subject = $result->row['msg_title'];
                        $this->body = $this->getFilteredText($result->row['msg_body']);
                        $this->messageDate = $result->row['mdate'];
                        $this->messageTime = $result->row['mtime'];
                        $this->selectedTabIndex = $this->isInbox ? 0 : 2;
                        if ($this->isInbox && !$result->row['is_readed'] && !$this->player->isSpy) {
                            $m->markMessageAsReaded($this->player->playerId, intval($_GET['id']));
                            --$this->data['new_mail_count'];
                        }
                    } else {
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 0;
                    }
                    $result->free();
                }
            }
        } else {
            if (isset($_POST['sm'])) {
                $this->receiver = trim($_POST['an']);
                $this->subject = trim($_POST['be']);
                $this->body = $_POST['message'];
                if (trim($this->receiver) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_noreceiver . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (trim($this->body) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_nobody . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (strtolower(trim($this->receiver)) == '[ally]' && 0 < intval($this->data['alliance_id']) && $this->hasAllianceSendMessageRole()) {
                    $pids = trim($m->getAlliancePlayersId(intval($this->data['alliance_id'])));
                    if ($pids != '') {
                        if ($this->subject == '') {
                            $this->subject = messages_p_emptysub;
                        }
                        $arr = explode(',', $pids);
                        foreach ($arr as $apid) {
                            if ($apid == $this->player->playerId) {
                                continue;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $apid, $m->getPlayerNameById($apid), $this->subject, $this->body);
                        }
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 2;
                    }
                } else {
                    $receiverPlayerId = $m->getPlayerIdByName($this->receiver);
                    if (0 < intval($receiverPlayerId)) {
                        if ($receiverPlayerId == $this->player->playerId) {
                            $this->showList = FALSE;
                            $this->selectedTabIndex = 1;
                            $this->errorText = '<b>' . messages_p_noloopback . '</b><p></p>';
                        } else {
                            if ($this->subject == '') {
                                $this->subject = messages_p_emptysub;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $receiverPlayerId, $this->receiver, $this->subject, $this->body);
                            $this->showList = TRUE;
                            $this->selectedTabIndex = 2;
                        }
                    } else {
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                        $this->errorText = messages_p_notexists . ' <b>' . $this->receiver . '</b><p></p>';
                    }
                }
            } else {
                if (isset($_POST['fm'])) {
                    $this->receiver = trim($_POST['an']);
                    $this->subject = trim($_POST['be']);
                    $this->body = $_POST['message'];
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->showFriendPane = TRUE;
                    if ($_POST['fm'] != '' && is_numeric($_POST['fm'])) {
                        $playerId = intval($_POST['fm']);
                        if (0 < $playerId && isset($this->friendList[$playerId])) {
                            unset($this->friendList[$playerId]);
                        }
                    } else {
                        if (isset($_POST['mfriends'])) {
                            foreach ($_POST['mfriends'] as $friendName) {
                                $friendName = trim($friendName);
                                if ($friendName == '') {
                                    continue;
                                }
                                $playerId = intval($m->getPlayerIdByName($friendName));
                                if (0 < $playerId && !isset($this->friendList[$playerId]) && $playerId != $this->player->playerId) {
                                    $this->friendList[$playerId] = $friendName;
                                    continue;
                                }
                            }
                        }
                    }
                    $friends = '';
                    foreach ($this->friendList as $k => $v) {
                        if ($friends != '') {
                            $friends .= '
';
                        }
                        $friends .= $k . ' ' . $v;
                    }
                    $m->saveFriendList($this->player->playerId, $friends);
                } else {
                    if (isset($_POST['rm'])) {
                        $this->receiver = trim($_POST['an']);
                        $this->subject = trim($_POST['be']);
                        $this->body = PHP_EOL . PHP_EOL . '_________________________________' . PHP_EOL . text_from_lang . ' ' . $this->receiver . ':' . PHP_EOL . PHP_EOL . $_POST['message'];
                        preg_match('/^(RE)\\^?([0-9]*):([\\w\\W]*)$/', $this->subject, $matches);
                        if (sizeof($matches) == 4) {
                            $this->subject = 'RE^' . ($matches[2] + 1) . ':' . $matches[3];
                        } else {
                            $this->subject = 'RE: ' . $this->subject;
                        }
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                    } else {
                        if (isset($_POST['dm'])) {
                            if (isset($_POST['dm'])) {
                                foreach ($_POST['dm'] as $messageId) {
                                    if ($m->deleteMessage($this->player->playerId, $messageId)) {
                                        --$this->data['new_mail_count'];
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($this->showList) {
            $rowsCount = $m->getMessageListCount($this->player->playerId, $this->selectedTabIndex == 0);
            $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
            $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) && intval($_GET['p']) < $this->pageCount ? intval($_GET['p']) : 0;
            $this->dataList = $m->getMessageList($this->player->playerId, $this->selectedTabIndex == 0, $this->pageIndex, $this->pageSize);
            if (0 < $this->data['new_mail_count']) {
                $this->data['new_mail_count'] = $m->syncMessages($this->player->playerId);
            }
        }
        $m->dispose();
    }
Пример #22
0
 public function clearHistoryAction()
 {
     $request = $this->get('request');
     // Force POST requests
     if (!$request->isPost()) {
         return $this->json(array('success' => false));
     }
     // Clear the history
     $success = MessageModel::repo()->clearHistory();
     if ($success) {
         // Log
         $this->get('logger')->info('History cleared');
     }
     return $this->json(array('success' => $success));
 }
Пример #23
0
 /**
  * Fire before every page render.
  *
  * @param Gdn_Controller $Sender
  */
 public function base_render_before($Sender)
 {
     $Session = Gdn::session();
     // Check the statistics.
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         Gdn::statistics()->check();
     }
     // Enable theme previewing
     if ($Session->isValid()) {
         $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', ''));
         $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
         if ($PreviewThemeName != '') {
             $Sender->Theme = $PreviewThemeName;
             $Sender->informMessage(sprintf(t('You are previewing the %s theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->isValid()) {
         $Confirmed = val('Confirmed', Gdn::session()->User, true);
         if (UserModel::requireConfirmEmail() && !$Confirmed) {
             $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->informMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->addModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::factory('Statistics');
         $Gdn_Statistics->check($Sender);
     }
     // Allow forum embedding
     if ($Embed = c('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = c('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->addDefinition('RemoteUrl', $RemoteUrl);
         }
         if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
             $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
         }
         // Force embedding?
         if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
             if (IsMobile()) {
                 $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
             } else {
                 $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
             }
             $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
             $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->addDefinition('Path', Gdn::request()->path());
         $get = Gdn::request()->get();
         unset($get['p']);
         // kludge for old index.php?p=/path
         $Sender->addDefinition('Query', http_build_query($get));
         // $Sender->addDefinition('MasterView', $Sender->MasterView);
         $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->addJsFile('vanilla.embed.local.js');
         } else {
             $Sender->addJsFile('embed_local.js');
         }
     } else {
         $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = val('X-UA-Device-Force', $_COOKIE);
     if ($ForceNoMobile === 'desktop') {
         $Sender->addAsset('Foot', wrap(Anchor(t('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
     // Allow global translation of TagHint
     $Sender->addDefinition("TagHint", t("TagHint", "Start to type..."));
 }
Пример #24
0
 /**
  *
  * @param Gdn_Controller $Sender
  */
 public function Base_Render_Before($Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         if ($PreviewThemeName != '') {
             $Sender->Theme = $PreviewThemeName;
             $Sender->InformMessage(sprintf(T('You are previewing the %s theme.'), Wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewThemeButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->IsValid()) {
         $ConfirmEmail = C('Garden.Registration.ConfirmEmail', false);
         $Confirmed = GetValue('Confirmed', Gdn::Session()->User, true);
         if ($ConfirmEmail && !$Confirmed) {
             $Message = FormatString(T('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->InformMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     // 2011-09-09 - mosullivan - No longer allowing messages in dashboard
     //		if ($Sender->MasterView == 'admin')
     //			$Exceptions[] = '[Admin]';
     //		else if (in_array($Sender->MasterView, array('', 'default')))
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->DeliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->Data('_NoMessages') && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions, $Sender->Data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->AddModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::Factory('Statistics');
         $Gdn_Statistics->Check($Sender);
     }
     // Allow forum embedding
     if ($Embed = C('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = C('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 SaveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->AddDefinition('RemoteUrl', $RemoteUrl);
         }
         // Force embedding?
         if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') {
             $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
             $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->AddDefinition('Path', Gdn::Request()->Path());
         // $Sender->AddDefinition('MasterView', $Sender->MasterView);
         $Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->AddJsFile('vanilla.embed.local.js');
         } else {
             $Sender->AddJsFile('embed_local.js');
         }
     } else {
         $Sender->SetHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile');
     if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) {
         $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
 }
Пример #25
0
 public function screen_applicant_process_close()
 {
     $btn1 = "";
     $btn2 = "";
     $reset = "";
     $this->make_message_form();
     if (empty($this->action)) {
         $MemberModel = new MemberModel();
         $CustomerModel = new CustomerModel();
         $member_data = $MemberModel->get_member_name_info_id($_SESSION['applicant']['member_id']);
         $project_data = $CustomerModel->get_project_title($_SESSION['applicant']['project_id']);
         $subject = "不採用のお知らせ";
         $body = $member_data['last_name'] . " " . $member_data['first_name'] . " 様\n\n";
         $body .= "このたびは下記のお仕事\n\n";
         $body .= "「" . $project_data . "」\n";
         $body .= "http://localhost/index.php?type=detail_project&project_id=" . $_SESSION['applicant']['project_id'] . "\n\n";
         $body .= "にご応募いただきありがとうございました。\n\n";
         $body .= "誠に残念でございますが、\n今回のお仕事は不採用となりました。\n\n";
         $body .= "何卒、ご了承いただけましたら\n幸いでございます。\n\n";
         $body .= $_SESSION[_CUSTOMER_AUTHINFO]['company_name'];
         $this->form->setDefaults(array('subject' => $subject, 'body' => $body));
         $this->form->freeze();
         $this->title = "見送り";
         $this->message = "不採用の通知をお送りして宜しいでしょうか?";
         $this->file = "customer_applicant_message_form.tpl";
         $this->next_type = "applicant_process_close";
         $this->next_action = "complete";
         $btn1 = "OK";
         $btn2 = "戻る";
     } else {
         if ($this->action == "complete" && isset($_POST['submit2']) && $_POST['submit2'] == "戻る") {
             $this->screen_applicant_detail();
             exit;
         } else {
             if ($this->action == "complete" && isset($_POST['submit1']) && $_POST['submit1'] == "OK") {
                 $data = $this->form->getSubmitValues();
                 $MessageModel = new MessageModel();
                 $ActionModel = new ActionModel();
                 $data['action_id'] = $ActionModel->get_action_some_id($_SESSION['applicant']['member_id'], $_SESSION['applicant']['project_id']);
                 $MessageModel->regist_customer_message_two_data($data, $_SESSION['applicant']);
                 $ActionModel = new ActionModel();
                 $history = "close";
                 $ActionModel->regist_action_history($_SESSION['applicant']['project_id'], $history);
                 $this->title = "お見送り完了";
                 $this->message = "不採用の通知の送付が完了しました。";
                 $this->file = "message.tpl";
                 unset($_SESSION['applicant']);
             }
         }
     }
     $this->form->addElement('submit', 'submit1', $btn1);
     $this->form->addElement('submit', 'submit2', $btn2);
     $this->view_display();
 }
Пример #26
0
 function kaixinMessageAction()
 {
     $title = "寒假不规划,开学差距大";
     $type = 1;
     $messageType = Common_Config::UDO_SCHOOL_MESSAGE_TYPE;
     $retry = 0;
     $result = -1;
     $messageModel = new MessageModel();
     $receiveUserId = $messageModel->kaixinUser();
     //print_r($receiveUserId);
     //print_r($receiveUserId);
     $text = "乐学课堂2016年最走心的陪伴式学习";
     //print_r($receiveUserId);
     //print_r($text);
     $custom_data_raw = json_encode(array("school_id" => 2782, "course_id" => "", "url" => "http://123.57.182.19:8520/"));
     $mid = $messageModel->messageLog($type, $messageType, $custom_data_raw, 0, $receiveUserId, null, $title, $text);
     $custom_data = json_encode(array("id" => $mid, "school_id" => 2782, "course_id" => "", "url" => "http://123.57.224.126:8524/", "prof_type" => 100, "title" => $title, "text" => $text));
     //print_r($custom_data);
     //如果发送失败,再尝试三次
     while ($retry <= 3 and $result == -1) {
         $result = $messageModel->sendMessage($type, $custom_data, $receiveUserId, $custom_data, $title, $text);
         //print_r($result);
         $retry++;
     }
     //print_r($retry);
     //print_r($result);
 }
Пример #27
0
 /**
  * Sends the message to the database layer
  * @param message string representation of message
  * @return boolean if succeeded or not
  */
 public function send(MessageModel $msg)
 {
     $message = $msg->getName();
     $text = $msg->getMessage();
     return $this->dal->insertMessage($message, $text);
 }
Пример #28
0
 public function generateTalkId()
 {
     // Find the last talk ID
     $result = self::$db->queryOne('SELECT MAX(talk_id) AS talk_id FROM ' . MessageModel::repo()->getTableName());
     return $result['talk_id'] + 1;
 }
Пример #29
0
 /**
  * Get what messages are active for a template location.
  *
  * @param $Location
  * @param array $Exceptions
  * @param null $CategoryID
  * @return array|null
  */
 public function getMessagesForLocation($Location, $Exceptions = array('[Base]'), $CategoryID = null)
 {
     $Session = Gdn::session();
     $Prefs = $Session->getPreference('DismissedMessages', array());
     if (count($Prefs) == 0) {
         $Prefs[] = 0;
     }
     $Exceptions = array_map('strtolower', $Exceptions);
     list($Application, $Controller, $Method) = explode('/', strtolower($Location));
     if (Gdn::cache()->activeEnabled()) {
         // Get the messages from the cache.
         $Messages = self::messages();
         $Result = array();
         foreach ($Messages as $MessageID => $Message) {
             if (in_array($MessageID, $Prefs) || !$Message['Enabled']) {
                 continue;
             }
             $MApplication = strtolower($Message['Application']);
             $MController = strtolower($Message['Controller']);
             $MMethod = strtolower($Message['Method']);
             $Visible = false;
             if (in_array($MController, $Exceptions)) {
                 $Visible = true;
             } elseif ($MApplication == $Application && $MController == $Controller && $MMethod == $Method) {
                 $Visible = true;
             }
             if ($Visible && !self::inCategory($CategoryID, val('CategoryID', $Message), val('IncludeSubcategories', $Message))) {
                 $Visible = false;
             }
             if ($Visible) {
                 $Result[] = $Message;
             }
         }
         return $Result;
     }
     $Result = $this->SQL->select()->from('Message')->where('Enabled', '1')->beginWhereGroup()->whereIn('Controller', $Exceptions)->orOp()->beginWhereGroup()->orWhere('Application', $Application)->where('Controller', $Controller)->where('Method', $Method)->endWhereGroup()->endWhereGroup()->whereNotIn('MessageID', $Prefs)->orderBy('Sort', 'asc')->get()->resultArray();
     $Result = array_filter($Result, function ($Message) use($CategoryID) {
         return MessageModel::inCategory($CategoryID, val('CategoryID', $Message), val('IncludeSubcategories', $Message));
     });
     return $Result;
 }
 public function courseindex()
 {
     $course_id = $_GET['id'];
     $course = new CourseModel();
     $message = new MessageModel();
     $usertype = Cookie::get('usertype');
     $username = Cookie::get('username');
     $userid = Cookie::get('userid');
     $courselist = $course->where("course_id='{$course_id}'")->find();
     $messagelist = $message->where("course_id='{$course_id}'")->select();
     $this->assign('course', $courselist);
     $this->assign('messagelist', $messagelist);
     $this->assign('usertype', $usertype);
     $this->assign('username', $username);
     $this->assign('userid', $userid);
     $this->display();
 }