/** * @Created By : Mahipal Singh Adhikari * @Created On : 27-Jan-2011 * @Description : Report Journal/Wall and other items as abuse to admin */ public function reportAbuseAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //get request parameters $item_id = $this->_getParam('item_id'); $item_type = $this->_getParam('item_type'); //get logged in user ID $usersNs = new Zend_Session_Namespace('members'); $user_id = $usersNs->userId; if ($user_id == "" || $user_id == 0) { $JsonResultArray = array('error' => 1, 'response' => "Please login to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_id == "" || $item_id == 0) { $JsonResultArray = array('error' => 2, 'response' => "No item is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_type == "") { $JsonResultArray = array('error' => 2, 'response' => "No item type is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } //Get user report abuse info for item $modelM = new Application_Model_ReportAbuse(); $modelRes = $modelM->fetchRow("item_id={$item_id} AND item_type='{$item_type}' AND user_id={$user_id}"); if ($modelRes && $modelRes->getStatus() == 1) { $JsonResultArray = array('error' => 2, 'response' => "You've already reported this as abuse."); echo Zend_Json::encode($JsonResultArray); exit; } else { $params["itemId"] = $item_id; $params["itemType"] = $item_type; $params["userId"] = $user_id; $params["comment"] = ""; $params["status"] = 1; $modelM->setOptions($params); $dbRes = $modelM->save(); if ($dbRes) { //get item type information $itemTitle = ""; $authorId = ""; $author = ""; if ($item_type == 'blog') { $blogM = new Application_Model_Blog(); $blogRes = $blogM->find($item_id); $itemTitle = $blogRes->getTitle(); $authorId = $blogRes->getUserId(); $blog_url = Zend_Registry::get('siteurl') . "/journal/view-post/blog_id/" . $item_id; $itemTitle = "<a href='" . $blog_url . "' target='_blank'>" . $itemTitle . "</a>"; } else { if ($item_type == 'wall') { $wallM = new Application_Model_Wall(); $wallRes = $wallM->find($item_id); $itemTitle = $wallRes->getStatus(); $authorId = $wallRes->getUserId(); } else { if ($item_type == 'photo') { $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $albumPhotoRes = $objModelAlbumPhoto->find($item_id); $itemTitle = $albumPhotoRes->getName(); $authorId = $albumPhotoRes->getUserId(); } } } //get Blog/Wall owner/author user information if ($authorId != "") { $useAuthor = new Application_Model_User(); $authorRes = $useAuthor->find($authorId); $author = ucfirst($authorRes->getFirstName()) . " " . ucfirst($authorRes->getLastName()) . " (" . $authorRes->getUsername() . ")"; } //get user information who is reporting abuse item $userM = new Application_Model_User(); $userR = $userM->find($user_id); $reporterName = ucfirst($userR->getFirstName()) . " " . ucfirst($userR->getLastName()) . " (" . $userR->getUsername() . ")"; $reporterEmail = $userR->getEmail(); //Now send report abuse email to Administrator $settings = new Admin_Model_GlobalSettings(); $admin_email = $settings->settingValue('report_abuse'); //$admin_email = "*****@*****.**"; $mailOptions['receiver_email'] = $admin_email; $mailOptions['item_type'] = ucfirst($item_type); $mailOptions['item_title'] = $itemTitle; $mailOptions['item_author'] = $author; $mailOptions['reporter_name'] = $reporterName; $mailOptions['reporter_email'] = $reporterEmail; //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendReportAbuseEmail($mailOptions); //send response $JsonResultArray = array('error' => 3, 'response' => "Consider it reported!"); } else { $JsonResultArray = array('error' => 2, 'response' => "Error occured, please try again later."); } } echo Zend_Json::encode($JsonResultArray); exit; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 1-Nov-2010 * @Description: Used to edit blog post information */ public function editBlogAction() { $request = $this->getRequest(); $form = new Application_Form_Blog(); $form->removeElement("weight"); //get blog information for edit $blog_id = $this->_getParam('id'); //$blog_id = base64_decode($blog_id); if (isset($blog_id)) { $objBlog = new Application_Model_Blog(); $blog = $objBlog->find($blog_id); //get blog tags $tag = new Application_Model_Tags(); $tags = $blog->getTags(); $tags = $tag->getTagsForEdit($blog_id); $blog_info["title"] = $blog->getTitle(); $blog_info["status"] = $blog->getStatus(); $blog_info["categoryId"] = $blog->getCategoryId(); $blog_info["location"] = $blog->getLocation(); $blog_info["tags"] = $tags; $blog_info["content"] = $blog->getContent(); $blog_info["comment"] = $blog->getComment(); $blog_info["publish"] = $blog->getPublish(); $blog_info["weight"] = $blog->getWeight(); $form->populate($blog_info); } $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } if ($this->getRequest()->isPost()) { $params = $request->getParams(); if ($form->isValid($params)) { $userNs = new Zend_Session_Namespace('members'); $journalM = new Application_Model_Journal(); $journal = $journalM->fetchRow("user_id='{$userNs->userId}'"); if (false !== $journal) { $params['userId'] = $userNs->userId; $params['journalId'] = $journal->getId(); $params['featured'] = $blog->getFeatured(); $params['weight'] = $blog->getWeight(); //$params['id'] = $blog_id; $blogM = new Application_Model_Blog($params); $blog = $blogM->save(); if ($blog && $blog_id != "") { //now first delete tags $albumTagM = new Application_Model_BlogTag(); //$objBlogTag = new Application_Model_BlogTag(); $albumTagM->delete("blog_id = {$blog_id}"); //insert/update blog tags if ($params['tags'] != "") { $arrTags = explode(",", $params['tags']); foreach ($arrTags as $_tag) { $_tag = trim($_tag); $tagsM = new Application_Model_Tags(); $tag = $tagsM->fetchRow("tag='{$_tag}'"); if (false === $tag) { $tagsM->setTag($_tag); $tag_id = $tagsM->save(); } else { $tag_id = $tag->getId(); } //$albumTagM=new Application_Model_BlogTag(); $albumTagM->setBlogId($blog_id); $albumTagM->setTagId($tag_id); $albumTagM->save(); } //end of foreach } //end of if /*----------tags-------*/ $_SESSION["flash_msg"] = "Journal post has been updated successfully."; $form->reset(); } else { $_SESSION["flash_msg"] = "Failed to update journal post. Please try again later."; } } else { $_SESSION["flash_msg"] = "Failed to update journal post because you have removed your journal."; } //redirect user //$this->_redirect('/journal/my-journals/'); $this->_redirect($this->view->seoUrl('/journal/my-journals/')); } //end of if } //end of if $this->view->form = $form; }
public function featureAction() { $id = $this->_getParam('id'); $model1 = new Application_Model_Blog(); $model = $model1->find($id); if ($model->getFeatured() == 1) { $model->setFeatured(0); $publish = "not featured"; } else { $model->setFeatured(1); $publish = "featured"; } $model->save(); return $this->_helper->redirector('index', 'journals', "admin", array('msg' => base64_encode("Blog [Id : {$model->getId()}] has been marked as {$publish}!"))); }
public function userLikeThisAction() { $this->_helper->layout->setLayout('journal-layout-2column'); //$item_id = $this->_getParam("blog_id"); $item_id = $this->_getParam("item_id"); $item_type = $this->_getParam("type"); //$userNs = new Zend_Session_Namespace('members'); //$this->view->userId = $userNs->userId; $item = false; $itemTypeText = ""; if ($item_type != "") { if ($item_type == 'blog') { $blogM = new Application_Model_Blog(); $this->view->blog = $item = $blogM->find($item_id); $itemTypeText = "Journal Post"; } if ($item_type == 'status_comment' || $item_type == 'blog_comment') { $commentM = new Application_Model_Comment(); $item = $commentM->find($item_id); $itemTypeText = "Comment"; $item_type = "comment"; } if ($item_type == 'status') { $wallM = new Application_Model_Wall(); $item = $wallM->find($item_id); $itemTypeText = "Wall Post"; } $this->view->itemTypeText = $itemTypeText; } //if item is not exists then redirect to Journal home page if (false === $item) { $this->_helper->redirector()->gotoUrl('/journal/index/'); exit; } //Now get all positive votes of item //$where = "item_id = $item_id AND vote=1 AND item_type='blog'"; $where = "item_id = {$item_id} AND vote=1"; if ($item_type == 'comment') { $where .= " AND (item_type='status_comment' OR item_type='blog_comment')"; } else { $where .= " AND item_type='{$item_type}'"; } $voteM = new Application_Model_Vote(); $rawdata = $voteM->fetchAll($where); //Get all users ID voted on an item if (false !== $rawdata) { $user_array = array(); foreach ($rawdata as $row) { $user_array[] = $row->getUserId(); } } //get all users information from above User Ids $this->view->totalUsers = 0; if (count($user_array) > 0) { $usrstr = implode(",", $user_array); $userM = new Application_Model_User(); $whereuser = "******"; $userData = $userM->fetchAll($whereuser, "first_name ASC"); $this->view->userData = $userData; $settings = new Admin_Model_GlobalSettings(); $page_size = $settings->settingValue('pagination_size'); //$page_size = 1; $page = $this->_getParam('page', 1); $pageObj = new Base_Paginator(); $paginator = $pageObj->fetchPageData($userM, $page, $page_size, $whereuser); $this->view->totalUsers = $pageObj->getTotalCount(); $this->view->paginator = $paginator; } }