本文整理匯總了PHP中Forum::delAttach方法的典型用法代碼示例。如果您正苦於以下問題:PHP Forum::delAttach方法的具體用法?PHP Forum::delAttach怎麽用?PHP Forum::delAttach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Forum
的用法示例。
在下文中一共展示了Forum::delAttach方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ajax_delete
public function ajax_delete()
{
if (!$this->RequestHandler->isPost() && !$this->RequestHandler->isDelete()) {
$this->error(ECode::$SYS_REQUESTERROR);
}
$this->_attOpInit();
$this->brief = true;
$u = User::getInstance();
if (isset($this->params['url']['name'])) {
$attName = nforum_iconv('utf-8', $this->encoding, $this->params['url']['name']);
try {
if (isset($this->params['id'])) {
$id = $this->params['id'];
$article = Article::getInstance($id, $this->_board);
if (!$article->hasEditPerm($u)) {
$this->error(ECode::$ARTICLE_NOEDIT);
}
$attNum = 0;
foreach ($article->getAttList() as $k => $v) {
if ($v['name'] == $attName) {
$attNum = intval($k + 1);
break;
}
}
$article->delAttach($attNum);
$this->set("postUrl", "/{$article->ID}");
} else {
Forum::delAttach($attName);
}
$this->set('ajax_code', ECode::$ATT_DELOK);
} catch (ArchiveAttException $e) {
$this->error($e->getMessage());
} catch (AttException $e) {
$this->error($e->getMessage());
} catch (Exception $e) {
$this->error(ECode::$ATT_NAMEERROR);
}
} else {
$this->error(ECode::$ATT_NAMEERROR);
}
}
示例2: delete
public function delete()
{
if (!$this->RequestHandler->isPost()) {
$this->error(ECode::$SYS_REQUESTERROR);
}
$this->_attOpInit();
$u = User::getInstance();
if (!isset($this->params['form']['name'])) {
$this->error(ECode::$ATT_NAMEERROR);
}
$attName = strval($this->params['form']['name']);
try {
if (isset($this->params['id'])) {
$id = $this->params['id'];
$article = Article::getInstance($id, $this->_board);
if (!$article->hasEditPerm($u)) {
$this->error(ECode::$ARTICLE_NOEDIT);
}
$attNum = 0;
foreach ($article->getAttList() as $k => $v) {
if ($v['name'] == $attName) {
$attNum = intval($k + 1);
break;
}
}
$article->delAttach($attNum);
$article = Article::getInstance($id, $this->_board);
} else {
Forum::delAttach($attName);
$article = Forum::listAttach();
}
$wrapper = Wrapper::getInstance();
$this->set('data', $wrapper->attachment($article));
return;
} catch (ArchiveAttException $e) {
$msg = $e->getMessage();
} catch (AttException $e) {
$msg = $e->getMessage();
} catch (Exception $e) {
$this->error();
}
}