/**
  * Unpin specific discussion
  * 
  * @param void
  * @return null
  *
  */
 function unpin()
 {
     if (!$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isAsyncCall());
     }
     // if
     if (!$this->active_discussion->canChangePinedState($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isAsyncCall());
     }
     // if
     $this->active_discussion->setIsPinned(false);
     $save = $this->active_discussion->save();
     if ($save && !is_error($save)) {
         flash_success('Discussion has been successfully unpinned');
         $activity_log = new DiscussionUnpinnedActivityLog();
         $activity_log->log($this->active_discussion, $this->logged_user);
     } else {
         flash_error('Failed to unpin selected discussion');
     }
     // if
     $this->redirectToReferer($this->active_discussion->getViewUrl());
 }
Ejemplo n.º 2
0
            break;
        default:
            $successURL = Url::discussion($discussion->getID());
    }
    $json = array('success' => '1', 'successUrl' => $successURL);
    echo json_encode($json);
} elseif ($action == 'reply') {
    $discussionID = Filter::numeric($_POST['discussionID']);
    $message = Filter::formattedText($_POST['message']);
    if ($message == '') {
        $json = array('error' => 'Your reply can not be blank.');
        exit(json_encode($json));
    }
    $discussion = Discussion::load($discussionID);
    $reply = new Discussion(array('creator_id' => Session::getUserID(), 'project_id' => $discussion->getProjectID(), 'parent_id' => $discussion->getID(), 'title' => $discussion->getTitle(), 'message' => $message, 'category' => $discussion->getCategory()));
    $reply->save();
    // attach any uploads
    // Upload::attachToItem(
    // $token,
    // Upload::TYPE_DISCUSSION,
    // $reply->getID(),
    // $project->getID()
    // );
    // log it
    $logEvent = new Event(array('event_type_id' => 'create_discussion_reply', 'project_id' => $discussion->getProjectID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $reply->getID(), 'item_2_id' => $discussion->getID(), 'data_1' => $message));
    $logEvent->save();
    // send email notification, if desired
    // discussion creator
    $creator = User::load($discussion->getCreatorID());
    if ($creator->getID() != Session::getUserID()) {
        // don't email yourself
Ejemplo n.º 3
0
 /**
  * Save Add Leg's discussion
  * CODE:
  */
 public function executeAddDiscussion(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $com_dis = $request->getParameter('comment_dis');
         $leg_id = $request->getParameter('dis_leg_id');
         if ($com_dis != null && strlen($request->getParameter('comment_dis')) <= 300) {
             if ($leg_id) {
                 $discussion = new Discussion();
                 $discussion->setLegId($leg_id);
                 $discussion->setUserId($this->getUser()->getId());
                 $discussion->setComment($request->getParameter('comment_dis'));
                 $discussion->setIsSplit($request->getParameter('is_split'));
                 $discussion->save();
                 $this->redirect('@request_legs?display=' . $leg_id . '#dis_form' . $leg_id);
             } else {
                 $this->getUser()->setFlash('form_' . $leg_id . '_error', 'Please fill comment to discussion!');
                 $this->redirect('@request_legs?display=' . $leg_id . '#dis_form' . $leg_id);
             }
         } else {
             $this->getUser()->setFlash('error', 'Please fill comment to discussion' . (strlen($request->getParameter('comment_dis')) > 300) ? ' with maximum of 300 characters!' : '!');
             $this->redirect('@request_legs?display=' . $leg_id);
         }
     }
 }