public function addAction() { $status = $this->getInput('startup_status'); // $config = new PwConfigSet('native'); if (count($_FILES)) { Wind::import('SRV:upload.action.PwStartUpUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwStartUpUpload(); $bhv->filename = 'startup'; // $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } // $filepath = $upload->getStore()->getAbsolutePath($data['filename'], $data['path']); $filecontent = file_get_contents($filepath); // $config->set('startup.imgmd5', md5($filecontent)); $config->set('startup.img', $data['path'] . $data['filename']); } $config->set('startup.status', $status)->flush(); $this->showMessage('ADMIN:success'); }
/** * * @access public * @return * @example * */ public function dosetAction() { /* $vd = function() { foreach(func_get_args() as $arg) { error_log(var_export($arg, true)); } }; */ $config = new PwConfigSet('notifier'); /* * 如果form的class是J_ajaxForm,可以只按照count($_FILES)来判断; * 如果不是,需要判断具体的tmp_name是否为空来判断是否选择了文件。 * */ if (count($_FILES) && !empty($_FILES['avatar']['tmp_name'])) { Wind::import('SRV:upload.action.PwStartUpUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwStartUpUpload(); $bhv->filename = 'avatar'; $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } // 添加进设置项 $config->set('avatar', $data['path'] . $data['filename']); } $nickname = $this->getInput('nickname'); if (empty($nickname)) { $nickname = PwLaiWangSerivce::$defaultNotifier['nickname']; } $usertype = intval($this->getInput('usertype')); if ($usertype != PwLaiWangSerivce::USERTYPE_NAME && $usertype != PwLaiWangSerivce::USERTYPE_ID) { $usertype = PwLaiWangSerivce::USERTYPE_NAME; } $user = $this->getInput('user'); if ($usertype == PwLaiWangSerivce::USERTYPE_NAME) { $userinfo = Wekit::load('user.PwUser')->getUserByName($user, PwUser::FETCH_MAIN); } else { $userinfo = Wekit::load('user.PwUser')->getUserByUid($user, PwUser::FETCH_MAIN); } if (empty($userinfo)) { $this->showError('NATIVE:user.notfound'); } $config->set('nickname', $nickname)->set('usertype', $usertype)->set('username', $userinfo['username'])->set('userid', $userinfo['uid'])->flush(); $this->showMessage('ADMIN:success', 'native/notifier/run/', true); }