public function actionList($postid) { $postid = (int) $postid; $post = AdminPost::model()->findByPk($postid); if ($post === null) { throw new CHttpException(404, t('post_is_not_exist', 'admin')); } $criteria = new CDbCriteria(); $criteria->addColumnCondition(array('post_id' => $postid)); $data = AdminComment::fetchList($criteria); $data['post'] = $post; $this->adminTitle = t('latest_comment', 'admin'); $this->render('list', $data); }
public function search() { $criteria = new CDbCriteria(); if ($this->postid) { $criteria->addColumnCondition(array('t.id' => $this->postid)); } else { if ($this->author) { $criteria->addColumnCondition(array('t.contributor' => $author, 't.user_name' => $this->author), 'OR'); } if ($this->keyword) { $criteria->addSearchCondition('t.title', $this->keyword); } } $data = $criteria->condition ? AdminPost::fetchList($criteria) : null; return $data; }
<div class="content list_content"> <section> <h1>Membros:</h1> <?php $empty = filter_input(INPUT_GET, 'empty', FILTER_VALIDATE_BOOLEAN); if ($empty) { WSErro("Oppss: você tentou editar um membro que não existe no sistema!", WS_INFOR); } $action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT); if ($action) { require_once '_models/AdminPost.class.php'; $postAction = filter_input(INPUT_GET, 'post', FILTER_VALIDATE_INT); $postUpdate = new AdminPost(); switch ($action) { case 'active': $postUpdate->ExeStatus($postAction, '1'); WSErro("O status do membro foi atualizado para <b>ativo</b>. Membro publicado!", WS_ACCEPT); break; case 'inative': $postUpdate->ExeStatus($postAction, '0'); WSErro("O status do membro foi atualizado para <b>inativo</b>. Membro agora é um rascunho!", WS_ACCEPT); break; case 'delete': $postUpdate->ExeDelete($postAction); WSErro('O membro ' . $postUpdate->getError()[0], $postUpdate->getError()[1]); break; default: WSErro("Ação não foi identificada pelo sistema, favor utilize os botões", WS_ERROR);
<header> <h1>Criar Post:</h1> </header> <?php $post = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Cadastrar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : null; unset($post['SendPostForm']); require '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeCreate($post); if ($cadastra->getResult()) { if (!empty($_FILES['gallery_covers']['tmp_name'])) { $sendGallery = new AdminPost(); $sendGallery->gbSend($_FILES['gallery_covers'], $cadastra->getResult()); } header('Location: painel.php?exe=posts/update&create=true&postId=' . $cadastra->getResult()); } else { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Enviar Capa:</span> <input type="file" name="post_cover" /> </label>
</label> <label class="checkbox"> <?php echo CHtml::activeCheckBox($model, 'istop'); echo t('settop', 'admin'); ?> </label> <label class="checkbox"> <?php echo CHtml::activeCheckBox($model, 'disable_comment'); echo t('disable_comment'); ?> </label> <label class="checkbox"> <?php echo CHtml::activeDropDownList($model, 'state', AdminPost::stateLabels(), array('class' => 'select-mini')); ?> </label> <button data-toggle="button" data-loading-text="<?php echo t('updating', 'admin'); ?> " data-error-text="<?php echo t('update_error', 'admin'); ?> " data-complete-text="<?php echo t('update_complete', 'admin'); ?> " class="btn-update-state btn btn-mini"><?php echo t('update', 'admin'); ?> </button>
?> <!--HOME CONTENT--> <section class="section"> <article class="col-md-12"> <!--<article>--> <div class="content artigos well"> <!--<div>--> <!--CABEÇALHO GERAL--> <?php if (!empty($Link->getLocal()[2])) { $action = $Link->getLocal()[2]; require_once 'admin/_models/AdminPost.class.php'; $postUpdate = new AdminPost(); switch ($action) { case 'active': $postUpdate->ExeStatus($post_id, '1'); $post_status = 1; WSErro("O status do post foi atualizado para <b>ativo</b>. Post publicado!", WS_ACCEPT); break; case 'inative': $postUpdate->ExeStatus($post_id, '0'); $post_status = 0; WSErro("O status do post foi atualizado para <b>inativo</b>. Post agora é um rascunho!", WS_ACCEPT); break; case 'delete': $postUpdate->ExeDelete($post_id); WSErro('O post ' . $postUpdate->getError()[0], $postUpdate->getError()[1]); break;
/** * Post admin action. */ public function adminAction() { $config = Zend_Registry::get('config'); $this->view->headScript()->appendFile($config->baseurl . '/js/jquery.validate.min.js'); $this->view->headScript()->appendFile($config->baseurl . '/js/create.js'); $id = $this->_getParam('id'); $city = $this->_getParam('city'); $advertisement = $this->advertisement->findById($id); if (empty($advertisement)) { throw new Exception('ID 缺失或者帖子没找到!'); } else { $this->view->view_id = $id; $form = new AdminPost($advertisement, $city); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { // $isValid = $this->_helper->common->validReCaptcha ( $this->_getAllParams() ); // if ($isValid) { $city = $form->getValue('city'); $action = $form->getValue('action'); $password = $form->getValue('password'); $cityObj = $this->city->findByName($city); if (!isset($cityObj)) { throw new Exception('暂时不支持所在城市!'); } switch ($action) { case 0: if ($password == $advertisement->password) { $db = Zend_Registry::get('db'); $db->beginTransaction(); $this->advertisement->closeAdvertisement($id); $db->commit(); $this->_redirect('/' . $city . '/bulletin/list'); } else { throw new Exception('没有权限关闭该帖子!'); } break; case 1: if ($password == $advertisement->password) { $form = new CreateOrUpdatePost($advertisement, $password, $cityObj); $this->view->form = $form; } else { throw new Exception('没有权限修改该帖子!'); } break; case 2: if ($password == '12345678') { $db = Zend_Registry::get('db'); $db->beginTransaction(); $this->advertisement->deleteAdvertisement($id); $db->commit(); $this->_redirect('/' . $city . '/bulletin/list'); } else { throw new Exception('没有权限删除该帖子!'); } break; } } } // } } }
/** * 批量设置热门文章 * @param array $ids 文章ID数组 * @param string $callback jsonp回调函数,自动赋值 */ public function actionMultiHottest($callback) { $ids = (array) request()->getPost('ids'); $successIds = $failedIds = array(); foreach ($ids as $id) { $model = AdminPost::model()->findByPk($id); if ($model === null) { continue; } $model->hottest = BETA_YES; $model->state = POST_STATE_ENABLED; $result = $model->save(true, array('hottest', 'state')); if ($result) { $successIds[] = $id; } else { $failedIds[] = $id; } } $data = array('success' => $successIds, 'failed' => $failedIds); BetaBase::jsonp($callback, $data); }
} ?> </ul> </div> <div class="label gbform"> <label class="label"> <span class="field">Enviar Arquivos:</span> <input type="file" multiple name="files[]" /> </label> <?php $delfl = filter_input(INPUT_GET, 'fldel', FILTER_VALIDATE_INT); if ($delfl) { require_once '_models/AdminPost.class.php'; $DellGallery = new AdminPost(); $DellGallery->flRemove($delfl); WSErro($DellGallery->getError()[0], $DellGallery->getError()[1]); } ?> <ul class="gallery"> <?php $gbi = 0; $Files = new WsPostsFile(); $Files->setPost_id($postid); $Files->Execute()->Query("#post_id#"); if ($Files->Execute()->getResult()) { foreach ($Files->Execute()->getResult() as $gb) { $gbi++;
<div class="content list_content"> <section> <h1>Cartilhas:</h1> <?php $empty = filter_input(INPUT_GET, 'empty', FILTER_VALIDATE_BOOLEAN); if ($empty) { WSErro("Oppss: você tentou editar uma cartilha que não existe no sistema!", WS_INFOR); } $action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT); if ($action) { require_once '_models/AdminPost.class.php'; $postAction = filter_input(INPUT_GET, 'post', FILTER_VALIDATE_INT); $postUpdate = new AdminPost(); switch ($action) { case 'active': $postUpdate->ExeStatus($postAction, '1'); WSErro("O status da cartilha foi atualizado para <b>ativo</b>. Post publicado!", WS_ACCEPT); break; case 'inative': $postUpdate->ExeStatus($postAction, '0'); WSErro("O status da cartilha foi atualizado para <b>inativo</b>. Post agora é um rascunho!", WS_ACCEPT); break; case 'delete': $postUpdate->ExeDelete($postAction); WSErro('A cartilha ' . $postUpdate->getError()[0], $postUpdate->getError()[1]); break; default: WSErro("Ação não foi identificada pelo sistema, favor utilize os botões", WS_ERROR);
$post = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Cadastrar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : null; $post['post_type'] = 'cartilhas'; unset($post['SendPostForm']); require '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeCreate($post); if ($cadastra->getResult()) { if (!empty($_FILES['gallery_covers']['tmp_name'])) { $sendGallery = new AdminPost(); $sendGallery->gbSend($_FILES['gallery_covers'], $cadastra->getResult()); } if (!empty($_FILES['files']['tmp_name'])) { $sendFiles = new AdminPost(); $sendFiles->flSend($_FILES['files'], $cadastra->getResult()); } header('Location: painel.php?exe=cartilhas/update&create=true&postId=' . $cadastra->getResult()); } else { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Enviar Capa:</span> <input type="file" name="post_cover" /> </label>
<div class="content form_create"> <article> <header> <h1>Criar Post:</h1> </header> <?php $post = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Cadastrar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : NULL; unset($post['SendPostForm']); require '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeCreate($post); var_dump($cadastra); } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Enviar Capa:</span> <input type="file" name="post_cover" /> </label> <label class="label"> <span class="field">Titulo:</span>
</label> </div><!--/line--> <div class="label gbform" id="gbfoco"> <label class="label"> <span class="field">Enviar Galeria:</span> <input type="file" multiple name="gallery_covers[]" /> </label> <?php $delGb = filter_input(INPUT_GET, 'gbdel', FILTER_VALIDATE_INT); if ($delGb) { require_once '_models/AdminPost.class.php'; $DellGallery = new AdminPost(); $DellGallery->gbRemove($delGb); WSErro($DellGallery->getError()[0], $DellGallery->getError()[1]); } ?> <ul class="gallery"> <?php $gbi = 0; $Gallery = new WsPostsGallery(); $Gallery->setPost_id($postid); $Gallery->Query("WHERE #post_id#"); if ($Gallery->getResult()) { foreach ($Gallery->getResult() as $gb) { $gbi++; ?> <li<?php
<div class="content form_create"> <article> <header> <h1>Criar Post:</h1> </header> <?php $post = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Cadastrar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : null; unset($post['SendPostForm']); require '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeCreate($post); if ($cadastra->getResult()) { header('Location: painel.php?exe=posts/update&create=true&postId=' . $cadastra->getResult()); } else { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <div class="label_line"> <label class="label_medium"> <span class="field">Enviar Capa:</span> <input type="file" name="post_cover" class="max"/>