Esempio n. 1
0
 * @copyright 2014 interactive32.com
 */
$this->attach('hook_data_renderoutput', 10, function (&$data) {
    $content =& $data['content'];
    $base_url = Application_Plugin_Common::getFullBaseUrl();
    $search_url = $base_url . '/search/posts/?term=%23';
    // hashtags
    $content = preg_replace("/(^|[\t\r\n\\s])#([\\p{L}\\p{N}\\-_]+)/u", " <a href='{$search_url}\$2'>#\$2</a> ", $content);
    // usertags
    $content = preg_replace("/(^|[\t\r\n\\s])@(\\w+)/u", " <a href='{$base_url}/\$2'>@\$2</a>", $content);
});
// push post mention notifications
$this->attach('hook_data_aftersavepost', 10, function ($data) {
    $post_id = $data['post_id'];
    $Posts = new Application_Model_Posts();
    $post = $Posts->getPost($post_id);
    $content = $data['content']['content'];
    $users = preg_replace_callback("/(^|[\t\r\n\\s])@(\\w+)/u", function ($match) use($post_id) {
        $Profiles = new Application_Model_Profiles();
        $profile = $Profiles->getProfile($match[2]);
        if ($profile && $profile->type == 'user') {
            $Notifications = new Application_Model_Notifications();
            $Notifications->pushNotification(array($profile->id), 1001, 'post', $post_id);
        }
    }, $content);
});
// push comment mention notifications
$this->attach('hook_data_aftersavecomment', 10, function ($data) {
    $comment_id = $data['comment_id'];
    $Comments = new Application_Model_Comments();
    $comment = $Comments->getComment($comment_id);
 /**
  * Edit reported post
  */
 public function editpostAction()
 {
     $Reports = new Application_Model_Reports();
     $total_counts = $Reports->getTotalCount();
     $this->buildMenu($total_counts);
     $request = $this->getRequest();
     $page = (int) $request->getParam('page');
     $post_id = (int) $request->getParam('post');
     $Posts = new Application_Model_Posts();
     $post = $Posts->getPost($post_id);
     // load and fill up form
     $edit_post_form = new Application_Form_EditPost();
     $edit_post_form->getElement('content')->setValue($post['content']);
     $edit_post_form->getElement('privacy')->setValue($post['privacy']);
     $this->view->edit_post_form = $edit_post_form;
     if ($request->isPost() && $edit_post_form->isValid($_POST)) {
         $content = $edit_post_form->getElement('content')->getValue();
         $privacy = $edit_post_form->getElement('privacy')->getValue();
         $new_post_content = Application_Plugin_Common::preparePost($content);
         $Posts->updatePost($post_id, $new_post_content, $privacy);
         Application_Plugin_Alerts::success($this->view->translate('Post updated'));
         if ($page > 0) {
             $this->redirect('reports/reviewposts/page/' . $page);
         }
     }
 }
 /**
  * get share modal content (via ajax)
  */
 public function shareAction()
 {
     $request = $this->getRequest();
     $resource_type = $request->getParam('resource_type', 0);
     $resource_id = $request->getParam('resource_id', 0);
     $base_link = Application_Plugin_Common::getFullBaseUrl();
     $repost_link = false;
     switch ($resource_type) {
         case 'post':
             $Posts = new Application_Model_Posts();
             $post = $Posts->getPost($resource_id);
             $profile = $Posts->getProfileDataByPostWall($resource_id);
             $profile_name = $profile['name'];
             $direct_link = $base_link . '/profiles/showpost/name/' . $profile_name . '/post/' . $resource_id;
             $repost_link = $base_link . '/posts/repost/post_id/' . $resource_id;
             break;
         case 'profile':
             $direct_link = $base_link . '/' . $resource_id;
             break;
         case 'image':
             $Images = new Application_Model_Images();
             $image = $Images->getImage($resource_id);
             $direct_link = $base_link . '/index/index/showimage/' . $image['data']['uid'];
             break;
         default:
             $direct_link = $base_link;
             break;
     }
     // drop repost link if not logged in
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $repost_link = false;
     }
     $this->view->repost_link = $repost_link;
     $this->view->direct_link = $direct_link;
     // trigger hooks
     Zend_Registry::get('hooks')->trigger('hook_app_share', $this);
     $html = $this->view->render('/partial/share_modal_content.phtml');
     $this->getHelper('json')->sendJson($html);
 }