コード例 #1
0
 *
 * @copyright   Copyright (C) 2010-2012 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */
require_once '../../approot.inc.php';
require_once APPROOT . '/application/application.inc.php';
require_once APPROOT . '/application/webpage.class.inc.php';
require_once APPROOT . '/application/ajaxwebpage.class.inc.php';
try {
    require_once APPROOT . '/application/startup.inc.php';
    //	require_once(APPROOT.'/application/user.preferences.class.inc.php');
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin(false, true);
    // Check user rights and prompt if needed
    $oPage = new ajax_page("");
    $oPage->no_cache();
    $sOperation = utils::ReadParam('operation', '');
    switch ($sOperation) {
        case 'add':
            $aResult = array('error' => '', 'att_id' => 0, 'preview' => 'false', 'msg' => '');
            $sObjClass = stripslashes(utils::ReadParam('obj_class', '', false, 'class'));
            $sTempId = utils::ReadParam('temp_id', '');
            if (empty($sObjClass)) {
                $aResult['error'] = "Missing argument 'obj_class'";
            } elseif (empty($sTempId)) {
                $aResult['error'] = "Missing argument 'temp_id'";
            } else {
                try {
                    $oDoc = utils::ReadPostedDocument('file');
                    $oAttachment = MetaModel::NewObject('Attachment');
                    $oAttachment->Set('expire', time() + 3600);