本文整理汇总了PHP中ArtefactTypeComment::set方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::set方法的具体用法?PHP ArtefactTypeComment::set怎么用?PHP ArtefactTypeComment::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_comment
/**
* Creates a comment from the given entry
*
* @param SimpleXMLElement $entry The entry to create the comment from
* @param PluginImportLeap $importer The importer
* @return array A list of artefact IDs created, to be used with the artefact mapping.
*/
private static function create_comment(SimpleXMLElement $entry, PluginImportLeap $importer)
{
$createdartefacts = array();
$comment = new ArtefactTypeComment();
$comment->set('title', (string) $entry->title);
$description = PluginImportLeap::get_entry_content($entry, $importer);
$type = isset($entry->content['type']) ? (string) $entry->content['type'] : 'text';
if ($type == 'text') {
$description = format_whitespace($description);
}
$comment->set('description', $description);
if ($published = strtotime((string) $entry->published)) {
$comment->set('ctime', $published);
}
if ($updated = strtotime((string) $entry->updated)) {
$comment->set('mtime', $updated);
}
$private = PluginImportLeap::is_correct_category_scheme($entry, $importer, 'audience', 'Private');
$comment->set('private', (int) $private);
$comment->set('owner', $importer->get('usr'));
if (isset($entry->author->name) && strlen($entry->author->name)) {
$comment->set('authorname', $entry->author->name);
} else {
$comment->set('author', $importer->get('usr'));
}
if (empty(self::$tempview)) {
self::create_temporary_view($importer->get('usr'));
}
$comment->set('onview', self::$tempview);
$comment->set('tags', PluginImportLeap::get_entry_tags($entry));
$comment->commit();
array_unshift($createdartefacts, $comment->get('id'));
return $createdartefacts;
}
示例2: delete_comment_submit
function delete_comment_submit(Pieform $form, $values)
{
global $SESSION, $USER, $view;
$comment = new ArtefactTypeComment((int) $values['comment']);
if ($USER->get('id') == $comment->get('author')) {
$deletedby = 'author';
} else {
if ($USER->can_edit_view($view)) {
$deletedby = 'owner';
} else {
if ($USER->get('admin')) {
$deletedby = 'admin';
}
}
}
$viewid = $view->get('id');
if ($artefact = $comment->get('onartefact')) {
$url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
} else {
$url = $view->get_url(false);
}
db_begin();
$comment->set('deletedby', $deletedby);
$comment->commit();
if ($deletedby != 'author') {
// Notify author
if ($artefact) {
$title = get_field('artefact', 'title', 'id', $artefact);
} else {
$title = get_field('view', 'title', 'id', $comment->get('onview'));
}
$title = hsc($title);
$data = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'commentdeletednotificationsubject', 'section' => 'artefact.comment', 'args' => array($title)), 'message' => (object) array('key' => 'commentdeletedauthornotification', 'section' => 'artefact.comment', 'args' => array($title, html2text($comment->get('description')))), 'urltext' => (object) array('key' => $artefact ? 'artefact' : 'view')), 'users' => array($comment->get('author')), 'url' => $url);
activity_occurred('maharamessage', $data);
}
if ($deletedby != 'owner' && $comment->get('owner') != $USER->get('id')) {
// Notify owner
$data = (object) array('commentid' => $comment->get('id'), 'viewid' => $view->get('id'));
activity_occurred('feedback', $data, 'artefact', 'comment');
}
db_commit();
$SESSION->add_ok_msg(get_string('commentremoved', 'artefact.comment'));
redirect(get_config('wwwroot') . $url);
}
示例3: setup_view_relationships_from_request
/**
* Fix comments to point to the right view. Probably more
* appropriate in setup_relationships. To do that we would have
* to change that call to happen after views are created.
*/
public static function setup_view_relationships_from_request(PluginImportLeap $importer)
{
if ($entry_requests = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ?', array($importer->get('importertransport')->get('importid'), 'comment'))) {
foreach ($entry_requests as $entry_request) {
$commentids = unserialize($entry_request->artefactmapping);
$comment = new ArtefactTypeComment($commentids[0]);
if ($comment->get('onartefact')) {
continue;
}
$entry = $importer->get_entry_by_id($entry_request->entryid);
$referentid = self::get_referent_entryid($entry, $importer);
if ($viewid = $importer->get_viewid_imported_by_entryid($referentid)) {
$comment->set('onview', $viewid);
$comment->commit();
} else {
// Nothing to link this comment to, so leave it in the temporary view.
self::$savetempview = true;
}
}
}
}