当前位置: 首页>>代码示例>>PHP>>正文


PHP Conversation::find_by_filename方法代码示例

本文整理汇总了PHP中Conversation::find_by_filename方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::find_by_filename方法的具体用法?PHP Conversation::find_by_filename怎么用?PHP Conversation::find_by_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversation的用法示例。


在下文中一共展示了Conversation::find_by_filename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<?php

include "../../inc/init.inc";
if (isset($_GET['conversation']) && $_GET['conversation'] != 0 && Follower::isFriend($res->user->id, $_GET['conversation'])) {
    $filename = $res->user->id > $_GET['conversation'] ? 'conversations/' . $_GET['conversation'] . "-" . $res->user->id . ".xml" : 'conversations/' . $res->user->id . "-" . $_GET['conversation'] . ".xml";
    if (!Conversation::exists(array('conditions' => array('filename' => $filename)))) {
        $attributes = array("user_id" => $res->user->id, "filename" => $filename);
        $conversation = Conversation::create($attributes);
    } else {
        $conversation = Conversation::find_by_filename($filename);
    }
    if ($conversation == null) {
        throw new Exception('can not init conversation', 504);
    }
    $xmlfile = VAR_PATH . $conversation->filename;
    // <editor-fold defaultstate="collapsed" desc="creation d'un message">
    if (isset($_GET['msg'])) {
        $msg = $_GET['msg'];
        $userChat = isset($_GET['userChat']) ? $_GET['userChat'] : "Invité";
        //Load it using simpleXML
        $doc = new DOMDocument();
        $doc->load($xmlfile);
        //Add a conversation item
        $item = $doc->createElement("item", $msg);
        //Add the sender's name as an attribute
        $sender = $doc->createAttribute("sender");
        $sender->appendChild($doc->createTextNode($userChat));
        //Add another attribute for time on which the message was added
        $time = $doc->createAttribute("time");
        $time->appendChild($doc->createTextNode(date("H:i", time())));
        //Put it together
开发者ID:Osin,项目名称:Intranet,代码行数:31,代码来源:talk.action.php


注:本文中的Conversation::find_by_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。