Ejemplo n.º 1
0
 public function getArticleMore($category_id = null)
 {
     $obj = new Application_Model_Articles();
     $where = "status='1'";
     if (!is_null($category_id)) {
         $where .= " AND category_id='{$category_id}'";
     }
     $entries = $obj->fetchAll($where, "title ASC");
     return $entries;
 }
 public function articleDetailAction()
 {
     //$this->_helper->viewRenderer->setNoRender(true);
     $blockM = new Base_View_Block();
     $path = "/layouts/scripts/page/blocks/work-study-volunteer";
     $blockM->removeBlock("work-study-volunteer-categories", 'work-study-volunteer');
     $params = $this->getRequest()->getParams();
     $article_id = $params['id'];
     $preview = false;
     $preview = $this->_getParam("preview");
     $categoryM = new Application_Model_Category();
     $articleM = new Application_Model_Articles();
     $data = $articleM->find($article_id);
     if (false != $data) {
         $this->view->article = $data;
         $this->view->preview = $preview;
         $this->view->categoryId = $categoryId = $data->getCategoryId();
         $this->view->categoryM = $categoryM->find($categoryId);
         $allarticles = $articleM->fetchAll("category_id = {$categoryId} and id != {$article_id}");
         /**
          * @Added By: Mahipal Adhikari
          * @Added On: 29-Dec-2010
          * @Description: get Article user information to display as Author
          */
         $userM = new Application_Model_User();
         $userRes = $userM->find($data->getUserId());
         $Author = "Admin";
         if (false !== $userRes) {
             $Author = $userRes->getFirstName() . " " . $userRes->getLastName();
             $this->view->author = $Author;
             $this->view->author_username = $userRes->getUsername();
         }
         if (count($allarticles) > 0) {
             $this->view->allarticles = $allarticles;
             $blocks = array("name" => "work-study-volunteer-articles", "order" => "8", "path" => $path);
             $blockM->addBlock($blocks, 'work-study-volunteer');
         }
     }
 }
Ejemplo n.º 3
0
 public function deleteAction()
 {
     $id = $this->_getParam('id');
     $model = new Application_Model_Articles();
     //added by Mahipal Adhikari on 5-jan-2011, move Article to deleted table before deleting permanently
     $db = Zend_Registry::get("db");
     $sSQL = "INSERT INTO articles_deleted SELECT * FROM articles WHERE id={$id}";
     $db->query($sSQL);
     //now delete article
     $model->delete("id={$id}");
     $_SESSION['errorMsg'] = "Article has been deleted successfully!";
     return $this->_helper->redirector('index', 'articles', "admin");
 }
Ejemplo n.º 4
0
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_Articles();
     $model = new Application_Model_Articles();
     $page_id = $this->_getParam('id');
     $this->view->msg = "";
     if ($this->_getParam('m') == 's') {
         $this->view->msg = "Advice category saved successfully";
     }
     /*-----------------------------------------*/
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $params = $form->getValues();
             $params['status'] = 1;
             $usersNs = new Zend_Session_Namespace("members");
             $params['userId'] = $usersNs->userId;
             $model = new Application_Model_Articles($params);
             $page_id = $model->save();
             $this->_helper->redirector('add', 'articles', 'admin', array('id' => $page_id, 'm' => 's'));
         }
     }
     $this->view->form = $form;
 }