示例#1
0
文件: save.php 项目: pleio/theme_ffd
<?php

elgg_make_sticky_form("cafe");
$guid = (int) get_input("guid");
$cafe = new ElggCafe($guid);
$adding = !$cafe->guid;
$editing = !$adding;
if (!$cafe instanceof ElggCafe) {
    register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
    forward(REFERER);
}
if ($editing && !$cafe->canEdit()) {
    register_error(elgg_echo("theme_ffd:cafe:nopermissions"));
    forward(REFERER);
}
$container_guid = (int) get_input("container_guid");
if (empty($container_guid)) {
    $container_guid = (int) $cafe->owner_guid;
}
if ($editing && $container_guid != $cafe->getContainerGUID()) {
    $moving = true;
}
if ($adding && !can_write_to_container(0, $container_guid, "object", "cafe")) {
    register_error(elgg_echo("theme_ffd:cafe:nopermissions"));
    forward(REFERER);
}
$title = get_input("title");
$description = get_input("description");
$purpose = get_input("purpose");
$tags = string_to_tag_array(get_input("tags", ""));
if (strlen($title) > 60) {
示例#2
0
<?php

$guid = (int) get_input("guid");
$cafe = new ElggCafe($guid);
if (!$cafe instanceof ElggCafe) {
    register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
    forward(REFERER);
}
if (!$cafe->canEdit()) {
    register_error(elgg_echo("theme_ffd:cafe:nopermissions"));
    forward(REFERER);
}
$result = $cafe->delete();
if ($result) {
    system_message(elgg_echo("theme_ffd:cafe:deleted"));
} else {
    register_error(elgg_echo("theme_ffd:cafe:notdeleted"));
}
forward('cafe');