We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8684
    • 29 Posts
    Hi, I’m using the docmanager class version0.5.3 from ur001 to create new document using the front end.
    the use of this class looks like that

    	require_once('assets/libs/docmanager/document.class.inc.php');
    	$doc = new Document();
    	$doc->Set('parent',$folder);
    	$doc->Set('alias','post'.time());
    	$doc->Set('content','document content');
    	$doc->Set('template','GuestBookComments');
    	$doc->Set('tvComment','post to comment');
    	$doc->Save();


    everything works fine, saving and stuff but when I click in my front end to display the content of the folder where my new doc is, it won’t appear although it appears clearly published in the manager tree, it is not in cache, i’ve even unchecked the put in cache checkbopx for all the doc in my modx site to be sure,
    i can only see it appear when i open the new doc and then just click on save, it’s like it refreshes the fact that there’s one new doc...

    have i missed something , is it something related to the docmanager class? is there something else i have to update somewhere so as for modx to take into account or to refresh the folder where my new document is?
      • 22588
      • 3 Posts
      Hey, I have absolutely the same problem. Did you solved it somehow?

      Added:
      Looks like everything works fine after I replaced the code of saving a document from the one used in NewsPublisher. So, after line 75 of document.class.inc.php I added:
      			$lastInsertId = $modx->db->getInsertId();
      			// put the document in the document_groups it should be in
      			// check that up_perms are switched on!
      			if($modx->config['use_udperms']==1) {
      				if(is_array($parentDocGroupsArray)) {
      					foreach ($parentDocGroupsArray as $dgKey=>$dgValue) {
      						$insertDocSql = "INSERT INTO ".$modx->getFullTableName('document_groups')."(document_group, document) values(".stripslashes($dgValue).", $lastInsertId)";
      						$insertDocRs = $modx->db->query($insertDocSql);
      						if(!$insertDocRs){
      							exit;
      						}
      					} // end foreach
      				} // end if doc group array exists
      			} // end if perms are used
      
      			// Handle privateweb
      			$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privateweb = 0 WHERE id='$lastInsertId';");
      			$privatewebSql =    "
      				SELECT DISTINCT ".$modx->getFullTableName('document_groups').".document_group 
      				FROM ".$modx->getFullTableName('document_groups').", ".$modx->getFullTableName('webgroup_access')." 
      				WHERE 
      				".$modx->getFullTableName('document_groups').".document_group = ".$modx->getFullTableName('webgroup_access').".documentgroup 
      				AND 
      				".$modx->getFullTableName('document_groups').".document = $lastInsertId;";
      				$privatewebIds = $modx->db->getColumn("document_group",$privatewebSql);
      				if(count($privatewebIds)>0) {
      					$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privateweb = 1 WHERE id = $lastInsertId;");	
      				}
      
      				// And privatemgr
      				$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privatemgr = 0 WHERE id='$lastInsertId';");
      				$privatemgrSql =    "
      					SELECT DISTINCT ".$modx->getFullTableName('document_groups').".document_group 
      					FROM ".$modx->getFullTableName('document_groups').", ".$modx->getFullTableName('membergroup_access')." 
      					WHERE 
      					".$modx->getFullTableName('document_groups').".document_group = ".$modx->getFullTableName('membergroup_access')." .documentgroup 
      					AND 
      					".$modx->getFullTableName('document_groups').".document = $lastInsertId;";
      					$privatemgrIds = $modx->db->getColumn("document_group",$privatemgrSql);
      					if(count($privatemgrIds)>0) {
      						$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privatemgr = 1 WHERE id = $lastInsertId;");	
      					}
      			// end of document_groups stuff!
      			// empty cache
      			include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
      			$sync = new synccache();
      			$sync->setCachepath("assets/cache/");
      			$sync->setReport(false);
      			$sync->emptyCache(); // first empty the cache	

      Maybe for someone it is not new, but I spent all day solving this problem.