本文整理汇总了PHP中Msg类的典型用法代码示例。如果您正苦于以下问题:PHP Msg类的具体用法?PHP Msg怎么用?PHP Msg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Msg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send(Msg $msg)
{
// Get template file path.
$templatePath = SPrintF('Notifies/Jabber/%s.tpl', $msg->getTemplate());
$smarty = JSmarty::get();
if (!$smarty->templateExists($templatePath)) {
throw new jException('Template file not found: ' . $templatePath);
}
$smarty->assign('Config', Config());
foreach (array_keys($msg->getParams()) as $paramName) {
$smarty->assign($paramName, $msg->getParam($paramName));
}
try {
$message = $smarty->fetch($templatePath);
} catch (Exception $e) {
throw new jException(SPrintF("Can't fetch template: %s", $templatePath), $e->getCode(), $e);
}
$recipient = $msg->getParam('User');
if (!$recipient['Params']['NotificationMethods']['Jabber']['Address']) {
throw new jException("JabberID not found for user: " . $recipient['ID']);
}
$taskParams = array('UserID' => $recipient['ID'], 'TypeID' => 'Jabber', 'Params' => array($recipient['Params']['NotificationMethods']['Jabber']['Address'], $message, $recipient['ID']));
$result = Comp_Load('www/Administrator/API/TaskEdit', $taskParams);
switch (ValueOf($result)) {
case 'error':
throw new jException("Couldn't add task to queue: " . $result);
case 'exception':
throw new jException("Couldn't add task to queue: " . $result->String);
case 'array':
return TRUE;
default:
throw new jException("Unexpected error.");
}
}
示例2: add
function add($params)
{
$re = $this->db->exec("insert into `progress` set \n\t\t\t\tbusiness_id=:business_id,\n\t\t\t\tprocess_id=:process_id,\n\t\t\t\tnote=:note,\n\t\t\t\tdate_end=:date_end,\n\t\t\t\tcreate_time=now()\n\t\t\t", $params);
if ($re == 1) {
include 'msg.php';
$msg = new Msg($params['business_id'], 'business');
$msg->pushMessage('工商注册', '尊敬的客户你的工商注册进度更新了');
}
return $re;
}
示例3: delete
public function delete($id)
{
try {
$msg = new Msg($id);
if (UserHelper::getProfileId() != $msg->getReceiver() and !UserHelper::isEditor()) {
throw new fValidationException('not allowed');
}
$msg->delete();
$this->ajaxReturn(array('result' => 'success'));
} catch (fException $e) {
$this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
}
}
示例4: beforeSave
public function beforeSave()
{
if ($this->id && $this->id == $this->parent_id) {
$this->parent_id = 0;
\Msg::add('Категория не может быть сама себе родителем');
}
}
示例5: editorAction
public function editorAction($module)
{
if (!file_exists(Module::getModulePath($module) . '/generatorHash.php')) {
Msg::add('Этот модуль был создан без помощи генератора. Возможности его изменения ограничены и могут привести к порче модуля', 'danger');
}
$this->view->page(['data' => compact('module')]);
}
示例6: actionNewmsg
public function actionNewmsg()
{
$model = new Msg();
if (isset($_POST['Msg'])) {
$model->uid = Yii::app()->user->id;
$model->time = time();
$model->state = 1;
$model->attributes = $_POST['Msg'];
if ($model->save()) {
$this->redirect_message('私信发送成功!', 'success', '3', $this->createUrl('msg/inbox'));
}
}
$fans = Follow::model()->findAll('touid = ' . Yii::app()->user->id);
$data = array('model' => $model, 'fans' => $fans);
$this->render('newmsg', $data);
}
示例7: twitter_process_messages
/**
* loop through twitter messages, put them to database and send them to qaul app
*/
function twitter_process_messages($data, $type)
{
foreach ($data as $item) {
// check if message already exists
$msg = MsgQuery::create()->filterByTwitterid($item->id_str)->findOne();
if (!$msg) {
// save message in data base
$msg = new Msg();
$msg->setType($type);
$msg->setName($item->user->screen_name);
$msg->setMsg($item->text);
$msg->setIp(get_qaul_setting('ip'));
$msg->setTime($item->created_at);
$msg->setStatus(0);
$msg->setTwitterid($item->id_str);
$msg->save();
// send message to qaul app
twitter_send2qaul($msg);
}
}
}
示例8: actionDelete
public function actionDelete($id)
{
//$this->loadModel($id)->delete();
$model = Msg::model()->findByPk($id);
if ($model->delete()) {
//添加成功时候的提示信息设置
/**
*setFlash getFlash hasFlash 几个方法
*/
Yii::app()->user->setFlash('shanchu', '删除成功!');
}
$this->redirect('./index.php?r=backend/msg/index');
}
示例9: message
function message($key = "message.defaultMessage", $scope = "global") {
$retval = "";
$sessionMsg = Session::load(MSG_SCOPE, $scope);
if (!empty($sessionMsg)) {
reset($sessionMsg);
$retval .= Msg::get("message.extra.warning");
foreach ($sessionMsg as $message) {
$retval .= "<div>".$message["string"]."</div>\n";
}
} else {
$retval = Msg::get("message.extra.tooltip").Msg::get($key);
}
return $retval;
}
示例10: _getAccessToken
/**
* @descrpition 从微信服务器获取微信ACCESS_TOKEN
* @return Ambigous|bool
*/
private static function _getAccessToken()
{
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . WECHAT_APPID . '&secret=' . WECHAT_APPSECRET;
$accessToken = Curl::callWebServer($url, '', 'GET');
if (!isset($accessToken['access_token'])) {
return Msg::returnErrMsg(MsgConstant::ERROR_GET_ACCESS_TOKEN, '获取ACCESS_TOKEN失败');
}
$accessToken['time'] = time();
$accessTokenJson = json_encode($accessToken);
//存入数据库
$db = new mysql();
$db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
$sql = "update accesstoken set access_token='" . $accessTokenJson . "' where id=1";
$db->query($sql);
return $accessToken;
}
示例11: _getAccessToken
/**
* @descrpition 从微信服务器获取微信ACCESS_TOKEN
* @return Ambigous|bool
*/
private function _getAccessToken()
{
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . WECHAT_APPID . '&secret=' . WECHAT_APPSECRET;
$accessToken = Curl::callWebServer($url, '', 'GET');
if (!isset($accessToken['access_token'])) {
return Msg::returnErrMsg(MsgConstant::ERROR_GET_ACCESS_TOKEN, '获取ACCESS_TOKEN失败');
}
$accessToken['time'] = time();
$accessTokenJson = json_encode($accessToken);
//存入数据库
/**
* 这里通常我会把access_token存起来,然后用的时候读取,判断是否过期,如果过期就重新调用此方法获取,存取操作请自行完成
*
* 请将变量$accessTokenJson给存起来,这个变量是一个字符串
*/
return $accessToken;
}
示例12: _getJsapiTicket
/**
* @descrpition 从微信服务器获取js sdk api_ticket
* @return Ambigous|bool
*/
private static function _getJsapiTicket()
{
$accessToken = AccessToken::getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . $accessToken;
$JsapiTicket = Curl::callWebServer($url, '', 'GET');
if (!isset($JsapiTicket['ticket'])) {
return Msg::returnErrMsg(MsgConstant::ERROR_GET_ACCESS_TOKEN, '获取js ticket失败');
}
$JsapiTicket['time'] = time();
$JsapiTicketJson = json_encode($JsapiTicket);
//存入数据库
$db = new mysql();
$db->connect(DBHOST, DBUSER, DBPASSWORD, DBNAME);
$sql = "update jsapiticket set ticket='" . $JsapiTicketJson . "' where id=1";
$db->query($sql);
return $JsapiTicket;
}
示例13: parseRequest
public function parseRequest($request)
{
if (!empty($request[$this->colName]['pass']) && !empty($request[$this->colName]['pass'])) {
if (empty($request[$this->colName]['pass'])) {
\Msg::add('Вы не ввели пароль в первое поле', 'danger');
return FALSE;
}
if (empty($request[$this->colName]['repeat'])) {
\Msg::add('Вы не ввели пароль во второе поле', 'danger');
return FALSE;
}
if ($request[$this->colName]['pass'] != $request[$this->colName]['repeat']) {
\Msg::add('Введенные пароли не совадают', 'danger');
return FALSE;
}
$this->activeForm->model->{$this->colName} = \App::$cur->users->hashpass($request[$this->colName]['pass']);
}
}
示例14: init
public function init()
{
\App::$cur->view->customAsset('js', '/static/moduleAsset/UserForms/js/formCatcher.js');
if (!empty($_POST['UserForms'])) {
foreach ($_POST['UserForms'] as $form_id => $inputs) {
$form = \UserForms\Form::get((int) $form_id);
if (!$form) {
continue;
}
$formRecive = new \UserForms\Recive();
$formRecive->user_id = (int) \Users\User::$cur->id;
$formRecive->form_id = (int) $form_id;
$data = [];
$error = false;
foreach ($form->inputs as $input) {
if (isset($inputs['input' . $input->id])) {
$data['input' . $input->id] = htmlspecialchars($inputs['input' . $input->id]);
} elseif ($input->required) {
$error = true;
Msg::add('Вы не заполнили поле: ' . $input->label);
} else {
$data['input' . $input->id] = '';
}
}
if (!$error) {
$formRecive->data = json_encode($data);
$formRecive->save();
}
}
if (!$error && !empty(App::$cur->config['site']['email'])) {
$text = '';
foreach ($form->inputs as $input) {
if (isset($inputs['input' . $input->id])) {
$text .= "<b>{$input->label}:</b> " . htmlspecialchars($inputs['input' . $input->id]) . "<br />";
}
}
if ($text) {
$text = 'Дата получения по серверному времени: ' . date('Y-m-d H:i:s') . '<br />Заполненые поля:<br />' . $text;
Tools::sendMail('noreply@' . INJI_DOMAIN_NAME, App::$cur->config['site']['email'], $form->name, $text);
}
}
Tools::redirect($_SERVER['REQUEST_URI'], 'Ваша форма была успешно отправлена', 'success');
}
}
示例15: datetime
function datetime($format, Date $date) {
// TODO you can only use dd MM yy yyyy HH mm ss
$format = Msg::get($format);
$patterns[0] = '/dd/';
$patterns[1] = '/MM/';
$patterns[2] = '/yyyy/';
$patterns[3] = '/yy/';
$patterns[4] = '/HH/';
$patterns[5] = '/mm/';
$patterns[6] = '/ss/';
$replacements[6] = sprintf("%02d", $date->date);
$replacements[5] = sprintf("%02d", $date->month);
$replacements[4] = sprintf("%04d", $date->year);
$replacements[3] = sprintf("%02d", $date->year % 100);
$replacements[2] = sprintf("%02d", $date->hour);
$replacements[1] = sprintf("%02d", $date->minute);
$replacements[0] = sprintf("%02d", $date->second);
echo preg_replace($patterns, $replacements, $format);
}