/**
  * Add status message
  * 
  * @param void
  * @return void
  */
 function add()
 {
     if (!$this->request->isApiCall() && !$this->request->isAsyncCall()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     $this->wireframe->print_button = false;
     if ($this->request->isSubmitted()) {
         $status_data = $this->request->post('status');
         $status_message = array_var($status_data, 'message');
         $status_message_parent = null;
         $status_message_parent_id = (int) array_var($status_data, 'parent_id');
         if ($status_message_parent_id) {
             $status_message_parent = StatusUpdates::findById($status_message_parent_id);
         }
         // if
         $this->active_status_update = new StatusUpdate();
         $this->active_status_update->setAttributes($status_data);
         $this->active_status_update->setCreatedById($this->logged_user->getId());
         $this->active_status_update->setCreatedByName($this->logged_user->getName());
         $this->active_status_update->setCreatedByEmail($this->logged_user->getEmail());
         $save = $this->active_status_update->save();
         if (!$save || is_error($save)) {
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED);
             }
             // if
         }
         // if
         if ($this->request->isApiCall()) {
             $this->serveData($this->active_status_update, 'message');
         } else {
             UserConfigOptions::setValue('status_update_last_visited', new DateTimeValue(), $this->logged_user);
             if (instance_of($status_message_parent, 'StatusUpdate')) {
                 $this->smarty->assign('status_update', $status_message_parent);
             } else {
                 $this->smarty->assign('status_update', $this->active_status_update);
             }
             // if
             print $this->smarty->fetch(get_template_path('_status_row', $this->controller_name, STATUS_MODULE));
             die;
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }