/**
  * Complete specific object
  *
  * @param void
  * @return null
  */
 function complete()
 {
     if (!$this->active_object->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     //BOF:mod 20110617
     //BOF:mod 20120917 (reversed by shawn)
     /*
     	//EOF:mod 20120917
           $object_type = $this->active_object->getType();
           if ($object_type=='Milestone' || $object_type=='Ticket'){
     		$responsible_assignee = $this->active_object->getResponsibleAssignee();
     		$created_by_id = $this->active_object->getCreatedById();
     		$project_leader = $this->active_project->getLeaderId();
     		if ( (!is_null($responsible_assignee) && $responsible_assignee->getId()==$this->logged_user->getId()) 
     	|| $created_by_id==$this->logged_user->getId() 
     	|| $project_leader==$this->logged_user->getId() 
     	|| $this->logged_user->isAdministrator() ){
     $warning = '';
     		} else {
                             $temp = new User(!empty($created_by_id) ? $created_by_id : $project_leader);
                             $warning = ($object_type=='Milestone' ? 'Project' : 'Ticket') . ' cannot be closed at this time. Please send message to ' . $temp->getName() . ' to close this ' . ($object_type=='Milestone' ? 'project' : 'ticket') . '.';
                             unset($temp);
     flash_error($warning, null, true);
     $this->redirectToUrl($this->active_object->getViewUrl());
     		}
     	  }
     //BOF:mod 20120917 (reversed by shawn)
     */
     //EOF:mod 20120917
     //EOF:mod 20110617
     if ($this->request->get('ajax_complete_reopen')) {
         if ($this->request->isSubmitted()) {
             db_begin_work();
             $action = $this->active_object->complete($this->logged_user);
             if ($action && !is_error($action)) {
                 db_commit();
             } else {
                 db_rollback();
             }
             // if
         }
         // if
         require_once SYSTEM_MODULE_PATH . '/helpers/function.object_complete.php';
         print smarty_function_object_complete(array('object' => $this->active_object, 'user' => $this->logged_user), $this->smarty);
         die;
     } else {
         $this->executeOnActiveObject('complete', array($this->logged_user, ''), lang(':type ":name" has been completed', array('type' => $this->active_object->getVerboseType(), 'name' => $this->active_object->getName())), lang('Failed to complete :type ":name"', array('type' => $this->active_object->getVerboseType(true), 'name' => $this->active_object->getName())));
     }
     // if
 }
 /**
  * Toggles object completed state
  * 
  */
 function toggle_completed()
 {
     $object_id = (int) $this->request->get('object_id');
     if ($object_id) {
         $object = ProjectObjects::findById($object_id);
     } else {
         $object = new ProjectObject();
     }
     // if
     if ($object->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if ($object->isCompleted()) {
         $object->open($this->logged_user);
     } else {
         $object->complete($this->logged_user);
     }
     $this->redirectToUrl(mobile_access_module_get_view_url($object));
 }