Example #1
0
if ($action == 'add') {
    $picture = new picture();
    if (isset($_REQUEST['cacheuuid'])) {
        $cache = cache::fromUUID($_REQUEST['cacheuuid']);
        if ($cache === null) {
            $tpl->error(ERROR_CACHE_NOT_EXISTS);
        }
        if ($cache->allowEdit() == false) {
            $tpl->error(ERROR_NO_ACCESS);
        }
        $picture->setObjectId($cache->getCacheId());
        $picture->setObjectType(OBJECT_CACHE);
        $cache = null;
    } else {
        if (isset($_REQUEST['loguuid'])) {
            $cachelog = cachelog::fromUUID($_REQUEST['loguuid']);
            if ($cachelog === null) {
                $tpl->error(ERROR_CACHELOG_NOT_EXISTS);
            }
            if ($cachelog->allowView() == false) {
                $tpl->error(ERROR_NO_ACCESS);
            } else {
                if ($cachelog->allowEdit() == false) {
                    $tpl->error(ERROR_NO_ACCESS);
                }
            }
            $picture->setObjectId($cachelog->getLogId());
            $picture->setObjectType(OBJECT_CACHELOG);
            $cachelog = null;
        } else {
            $tpl->error(ERROR_INVALID_OPERATION);