Esempio n. 1
0
 /**
  * @param integer $fileId
  * @throws TasksException
  * @throws CTaskAssertException
  * 
  * This function is deprecated, it wont work with a new disk-based file attachment mechanism
  * 
  * @deprecated
  */
 public function removeAttachedFile($fileId)
 {
     CTaskAssert::assertLaxIntegers($fileId);
     CTaskAssert::assert($fileId > 0);
     if (!$this->isActionAllowed(self::ACTION_EDIT)) {
         CTaskAssert::log('access denied while trying to remove file: fileId=' . $fileId . ', taskId=' . $this->taskId . ', userId=' . $this->executiveUserId, CTaskAssert::ELL_WARNING);
         throw new TasksException('', TasksException::TE_ACTION_NOT_ALLOWED);
     }
     if (!CTaskFiles::Delete($this->taskId, $fileId)) {
         throw new TasksException('File #' . $fileId . ' not attached to task #' . $this->taskId, TasksException::TE_FILE_NOT_ATTACHED_TO_TASK);
     }
 }
Esempio n. 2
0
 function DeleteAttachment($listName, $listItemID, $url)
 {
     if (!$this->__Init()) {
         return $this->error;
     }
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listItemID = intval($listItemID);
     $pos = strrpos($url, '/');
     if ($pos) {
         $fileName = ToLower(str_replace(array('/', '\\', '..'), '', substr($url, $pos + 1)));
     }
     // minor security
     if (!$fileName) {
         return new CSoapFault('Wrong file', 'Wrong file URL');
     }
     $dbRes = CTaskFiles::GetList(array(), array("TASK_ID" => $listItemID));
     while ($taskFile = $dbRes->Fetch()) {
         $FILE_NAME = ToLower(basename(CFile::GetPath($taskFile["FILE_ID"])));
         if ($FILE_NAME == $fileName) {
             $rsTask = CTasks::GetList(array(), array("ID" => $listItemID), array("ID"));
             if ($arTask = $rsTask->Fetch()) {
                 if (CTasks::CanCurrentUserEdit($arTask["ID"])) {
                     // We got this task only if user has rights on edit it.
                     CTaskFiles::Delete($taskFile["TASK_ID"], $taskFile["FILE_ID"]);
                 }
             }
             break;
         }
     }
     return array('DeleteAttachmentResult' => '');
 }