示例#1
0
 public function setDefaultJournal($user_id)
 {
     $userM = new Application_Model_User();
     $user = $userM->find($user_id);
     if (false !== $user) {
         $journalM = new Application_Model_Journal();
         $journalM->setTitle($user->getFirstName() . "'s Journal");
         $journalM->setPublish("published");
         $journalM->setStatus("public");
         $journalM->setUserId($user_id);
         $journalM->save();
         return true;
     }
     return false;
 }
示例#2
0
 /**
  * @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;
 }
示例#3
0
 private function setModel($row)
 {
     $model = new Application_Model_Journal();
     $model->setId($row->id)->setTitle($row->title)->setStatus($row->status)->setPublish($row->publish)->setUserId($row->user_id)->setAddedon($row->addedon)->setUpdatedon($row->updatedon);
     return $model;
 }
示例#4
0
 public function journalSettingsAction()
 {
     $this->_helper->layout->setLayout('3column-my-account');
     $this->view->siteUrl = Zend_Registry::get('siteurl');
     $request = $this->getRequest();
     $userNs = new Zend_Session_Namespace('members');
     $journalM = new Application_Model_Journal();
     $journal = $journalM->fetchRow("user_id='{$userNs->userId}'");
     //added by Mahipal Adhikari on 24-dec-2010
     $this->view->noJournal = 0;
     //journal is not published
     if (false !== $journal) {
         //added by Mahipal Adhikari on 24-dec-2010
         if ($journal->getPublish() == "published") {
             $this->view->noJournal = 1;
             //journal is published
         }
         $this->view->userId = $userNs->userId;
         if ($this->getRequest()->isPost()) {
             $params = $request->getParams();
             if (isset($params['save'])) {
                 $journal->setTitle($params['title']);
                 $journal->setStatus($params['status']);
                 if ($journal->save()) {
                     //update user permission settings
                     $permission_id = 4;
                     $where = "user_id='{$userNs->userId}' AND permission_id={$permission_id}";
                     $user_permission = new Application_Model_UserPermission();
                     $user_permission = $user_permission->fetchRow($where);
                     if (false !== $user_permission) {
                         $user_permission->setFriendGroupId($params["friend_group_id"]);
                         $user_permission->save();
                     }
                     $this->view->success = 1;
                 } else {
                     $this->view->success = 0;
                 }
             } else {
                 if (isset($params['remove'])) {
                     $journal->setPublish('trash');
                     if ($journal->save()) {
                         $this->_helper->redirector('journal-settings', 'journal', "default");
                     }
                 } else {
                     if (isset($params['activate'])) {
                         $journal->setPublish('published');
                         if ($journal->save()) {
                             $this->_helper->redirector('journal-settings', 'journal', "default");
                         }
                     } else {
                         if (isset($params['view'])) {
                             //$this->_helper->redirector('my-journals','journal',"default");
                             $this->_redirect($this->view->seoUrl('/journal/my-journals/'));
                         }
                     }
                 }
             }
         }
         $this->view->title = $journal->getTitle();
         $this->view->status = $journal->getStatus();
     } else {
         $this->view->error_msg = "No Journal is found for your profile, please contact System Administrator.";
     }
 }