Esempio n. 1
0
function deleteDocument($uid)
{
    DOCMAN_token::check() or die('Invalid Token');
    global $database, $_DMUSER;
    $doc = new mosDMDocument($database);
    $doc->load($uid);
    //check user permissions
    $err = $_DMUSER->canPreformTask($doc, 'Delete');
    if ($err) {
        _returnTo('cat_view', $err, $doc->catid);
    }
    //delete the docmument
    $doc->remove(array($uid));
    _returnTo('cat_view', _DML_DOCDELETED, $doc->catid);
}
Esempio n. 2
0
function downloadDocument($bid)
{
    global $_DOCMAN;
    $database = JFactory::getDBO();
    // load document
    $doc = new mosDMDocument($database);
    $doc->load($bid);
    // download file
    $file = new DOCMAN_File($doc->dmfilename, $_DOCMAN->getCfg('dmpath'));
    $file->download();
    die;
    // Important!
}
Esempio n. 3
0
 /**
  * @desc 	Transform the document to a object if necessary
  * @param 	mixed	object or numeric $doc
  * @access  	private
  * @return 	object 	a document object
  */
 function isDocument(&$doc)
 {
     $database = JFactory::getDBO();
     // check to see if we have a object
     if (!is_a($doc, 'mosDMDocument')) {
         $id = $doc;
         // try to create a document db object
         if (is_numeric($id)) {
             $doc = new mosDMDocument($database);
             $doc->load($id);
         }
     }
 }
Esempio n. 4
0
 function copy($cid, $catid)
 {
     global $database, $my;
     if (!is_array($cid) || count($cid) < 1) {
         echo "<script> alert('" . _DML_SELECT_ITEM_COPY . " ); window.history.go(-1);</script>\n";
         return false;
     }
     foreach ($cid as $id) {
         $docold = new mosDMDocument($database);
         $docnew = new mosDMDocument($database);
         $docold->load($id);
         $docnew->bind((array) $docold);
         $docnew->id = 0;
         $docnew->catid = $catid;
         if ($docold->catid == $docnew->catid) {
             $docnew->dmname = _DML_COPY_OF . ' ' . $docnew->dmname;
         }
         $docnew->store();
     }
     return true;
 }