Пример #1
0
 public static function mapObjectToModel(Zend_Db_Table_Row_Abstract $row, Application_Model_Post $post = null)
 {
     if (null === $post) {
         $post = new Application_Model_Post();
     }
     $post->setId($row->id)->setTitle($row->title)->setBody($row->body)->setCreated($row->created);
     return $post;
 }
Пример #2
0
 public function deleteAction()
 {
     // action body
     $id = $this->_request->getParam('id');
     if (!empty($id)) {
         $post_model = new Application_Model_Post();
         $post_model->deletePost($id);
     }
     $this->redirect('/');
 }
Пример #3
0
 public function tabAction()
 {
     if ($this->auth->hasIdentity()) {
         $userid = $this->getRequest()->getParam('userid');
         $tab = $this->getRequest()->getParam('tab');
         if ($tab == 'scribbles') {
             $getscribbles = new Application_Model_Post($this->registry['DB']);
             $this->view->results = $getscribbles->getUserPosts($userid);
         }
     }
 }
 public function indexAction()
 {
     $form = new Application_Form_Post();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $post = new Application_Model_Post($form->getValues());
             $post->save();
             // reset the form
             $form->reset();
         }
     }
     // show all posts
     $posts = new Application_Model_Post();
     $this->view->form = $form;
     $this->view->posts = $posts->fetchAll();
 }
Пример #5
0
 private function __setAttribute($postObj)
 {
     if (count($postObj) == 1) {
         $post = new Application_Model_Post();
         $post->setOptions(array("postId" => $postObj->post_id, "message" => $postObj->message, "highlight" => $postObj->highlight, "pinToTop" => $postObj->pin_to_top, "isTagged" => $postObj->is_tagged, "milestoneId" => $postObj->milestone_id, "eventId" => $postObj->event_id, "imageId" => $postObj->image_id, "videoId" => $postObj->video_id, "pollId" => $postObj->poll_id, "schedule" => $postObj->schedule, "privacy" => $postObj->privacy, "type" => $postObj->type, "isPosted" => $postObj->is_posted, "addtime" => $postObj->addtime, "updtime" => $postObj->updtime));
         return $post;
     } elseif (count($postObj) > 1) {
         $postList = array();
         foreach ($postObj as $row) {
             $post = new Application_Model_Post();
             $post->setOptions(array("postId" => $row->post_id, "message" => $row->message, "highlight" => $row->highlight, "pinToTop" => $row->pin_to_top, "isTagged" => $row->is_tagged, "milestoneId" => $row->milestone_id, "eventId" => $row->event_id, "imageId" => $row->image_id, "videoId" => $row->video_id, "pollId" => $row->poll_id, "schedule" => $row->schedule, "privacy" => $row->privacy, "type" => $row->type, "isPosted" => $row->is_posted, "addtime" => $row->addtime, "updtime" => $row->updtime));
             $postList[] = $post;
         }
         return $postList;
     }
 }
Пример #6
0
 public function indexAction()
 {
     // action body
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $post_model = new Application_Model_Post();
         $this->view->posts = $post_model->listPosts();
         $namespace = new Zend_Session_Namespace();
         $this->view->role = $namespace->role;
         $this->view->username = $namespace->username;
     } else {
         $post_model = new Application_Model_Post();
         $this->view->posts = $post_model->listPosts();
         $this->view->msg = "not login";
     }
 }
Пример #7
0
 public function editAction()
 {
     $id = $this->_request->getParam('id');
     $this->view->action = 'edit';
     if (!empty($id)) {
         $this->view->post_data = $this->_request->getParams();
         $post_model = new Application_Model_Post();
         $posts = $post_model->getPostById($id);
         $this->view->post = $posts[0];
     }
     if ($this->_request->isPost()) {
         $post_data = $this->_request->getParams();
         //var_dump($post_data);
         $post_model = new Application_Model_Post();
         $post_model->editPost($id, array("title" => $post_data['title'], "body" => $post_data['postbody']));
         $posts = $post_model->getPostById($id);
         $this->view->post = $posts[0];
     }
     $this->render('add');
     //$post=new Application_Model_Post()
     // $post->editPost($this->$id,);
 }
Пример #8
0
 public function myStreams($ruserid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('activity', array('activityid', 'userid', 'ruserid', 'contentid', 'title', 'contenttype', 'contenturl', 'alternate_contentid', 'date'))->joinLeft('freniz', 'freniz.userid=activity.ruserid', array('ruserid' => 'userid', 'rusername' => 'username', 'ruserurl' => 'url'))->joinLeft('image', 'image.imageid=freniz.propic', 'image.url as ruserimageurl')->where('ruserid=?', $ruserid)->where('(contenttype=\'post\' and activity.title=\'posted on\') or (contenttype=\'video\' and activity.title=\'post a video on\') or (contenttype=\'image\' and activity.title=\'post image\' and activity.userid!=?) or (contenttype in (\'propic\',\'basicinfo\',\'personalinfo\',\'mood\',\'city\'))', $ruserid);
         $results = $this->_db->fetchAssoc($sql);
         $myStreamsMapper = array();
         foreach ($results as $id => $values) {
             switch ($values['contenttype']) {
                 case 'post':
                     $myStreamsMapper['posts'][$id] = $values['contentid'];
                     break;
                 case 'image':
                     $myStreamsMapper['images'][$id] = $values['contentid'];
                     break;
                 case 'video':
                     $myStreamsMapper['videos'][$id] = $values['contentid'];
                     break;
             }
         }
         if (!empty($myStreamsMapper['posts'])) {
             $posts = new Application_Model_Post($this->_db);
             $myStream_results['post'] = $posts->getPosts($myStreamsMapper['posts']);
         }
         if (!empty($myStreamsMapper['images'])) {
             $images = new Application_Model_Images($this->_db);
             $myStream_results['image'] = $images->getArrayOfImages($myStreamsMapper['images']);
         }
         if (!empty($myStreamsMapper['videos'])) {
             $videos = new Application_Model_Videos($this->_db);
             $myStream_results['video'] = $videos->getVideos($myStreamsMapper['videos']);
         }
         $final_results['mystream'] = $results;
         $final_results['results'] = $myStream_results;
         $sql = $this->_db->select()->from('commentactivity', 'max(id) as maxcomment');
         $result = $this->_db->fetchRow($sql);
         $final_results['maxcomment'] = $result['maxcomment'];
         return $final_results;
     }
 }
 public function getcommentsAction()
 {
     $postid = $this->getRequest()->getParam('scribbleid');
     $from = $this->getRequest()->getParam('from');
     if (empty($from) && !(is_int($from) || ctype_digit($from))) {
         $from = 0;
     }
     $staturemodel = new Application_Model_Post($this->registry->DB);
     $this->view->postid = $postid;
     $this->view->results = $staturemodel->getComments($postid, $from);
 }