Code Segment

SharePoint - Adding "View All Folders" under Related Tasks menu in document library folders

Jan 30 2006 by csegura @ 23:39

Some time ago I write a post with a little trick to add this "missed" option ["View all folders" in Document Libraries]. Now I have needed it in all my documents libraries and the best option is as always modify the list schema file.

Each list definition contains a schema.xml that defines the views, forms, toolbar, and special fields in a list definition. In my production server I have modified the DOCLIB template in "web server extensions\60\TEMPLATE\3082\STS\LISTS\DOCLIB"

Using your favorite CAML Editor .... :-) adds the next code after first HTML Tag under Toolbar (relatedtasks) tag entry.

<HTML>
    <![CDATA[
     <script language="Javascript">
    function LayoutsLink(aspxFullUrl)
    {
       var rootFolder = GetUrlKeyValue("RootFolder");
       if (rootFolder != "")
           aspxFullUrl += "&RootFolder=" + rootFolder;
       window.location.href = aspxFullUrl;
    }
    </script>
    <tr> 
    <td style="padding-left: 2px;padding-bottom: 2px" width=100%&gt; 
    &lt;table border=0 cellpadding=0 cellspacing=0 width=100%&gt; 
    &lt;tr> 
    <td width=100% class="ms-unselectednav" colspan=2> 
    <table cellpadding=0 cellspacing=0 border=0> 
    <tr> 
    <td valign=top> 
    <img src="/_layouts/images/rect.gif">&nbsp; </td> 
    <td>
    <A ACCESSKEY="p" ID="diidFolderListButton" HREF="javascript:" onClick="javascript:LayoutsLink(']]>
</HTML>
 
<HTML>
   <![CDATA[/_layouts/<%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%>/folders.aspx?List=]]>
</HTML>
 
<HTML>
   <![CDATA[');javascript:return false;">]]>
</HTML>
 
<HTML>Ver todas las carpetas</HTML>
 
<HTML>
   <![CDATA[</A></td> </tr> </table> </td> </tr> </table> </td> </tr>]]>
</HTML>

The final result is as shown in the image.

            and the folder view 

Comments (0)

SharePoint - Using ajax to query exchange server (2)

Jan 27 2006 by csegura @ 22:03

Part 2

Changing the dav web query, you can get more data (see urn:content-classes:message and Default Exchange Store Namespaces for other namespaces) now to complete the sample the new query is

SELECT "urn:schemas:httpmail:datereceived", 
"DAV:href",
"urn:schemas:httpmail:sendername",
"urn:schemas:httpmail:subject"
FROM scope('shallow traversal of ') WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False

And to watch the xml results obtained by the query we can modify the checkState function. 

function checkState()

{
  if (xmlHttpReq.readyState == 4)
  {
    divOutput.innerText = xmlHttpReq.ResponseXML.xml;
  }
}

Better than parse DOM to get the results I prefer use XSL, now I can copy the XML results in my favorite XSLT editor and map the data. After I can add the xsl to the page and transform the xml usig it. The final result is as shown in the image.

 

<script language=javascript>
var sUser = "USERNAME";
var sExchangeServer = "http://SERVER";
var sFolder = "FOLDER";
 
var xmlHttpReq;
 
function getMessages()
{
    .....
     
        var sDavQuery = 'SELECT  "urn:schemas:httpmail:datereceived", ' +
                              '"urn:schemas:httpmail:sendername", ' +
                              '"DAV:href", ' +
                              '"urn:schemas:httpmail:subject" ' +
                        ' FROM scope(\'shallow traversal of "' + sURL + '"\' )' +
                           ' WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False ';
                           
    .....
}
 
 
function checkState()
{
  if (xmlHttpReq.readyState == 4)
  {
    var xml = xmlHttpReq.ResponseXML;
    divOutput.innerHTML = xml.transformNode(xslTemplate.documentElement);        
  }
}
getMessages();
 
</script>
<div id='divOutput'></div>
 
<xml id='xslTemplate'>
 
   <xsl:template xmlns:xsl='uri:xsl' xmlns:a='DAV:' xmlns:d='urn:schemas:httpmail:'>
      <table>
      
          <tr class="ms-TPHeader">
            <td> Date </td>
            <td> From </td>
            <td> Subject </td>
          </tr>
          
         <xsl:for-each select='a:multistatus/a:response/a:propstat/a:prop'>
            <tr class="ms-WPBody">
               <td>
                  <xsl:value-of select='d:datereceived' />
               </td>
               <td>
                  <xsl:value-of select='d:sendername' />
               </td>
               <td>
                  <a>
                     <xsl:attribute name='href'>
                     <xsl:value-of select='a:href' />
 
                     /?Cmd=open</xsl:attribute>
 
                     <xsl:attribute name='target'>_blank</xsl:attribute>
 
                     <xsl:value-of select='d:subject' />
                  </a>
               </td>
            </tr>
         </xsl:for-each>
      </table>
   </xsl:template>
 
</xml>

Comments (0)

SharePoint - Using ajax to query exchange server (1)

Jan 26 2006 by csegura @ 19:20

We can use asynchronous data retrieval, inside of a WebContent webpart, this is a little sample of how to do it.

Part 1

Querying an exchange server and retry results inside of sharepoint webpart, this first sample use the Search web dav method using XMLHTTP request (Exchange Store WebDAV Protocol), query the last five elements from user inbox and gets the date received, the sender name and the subject.

SELECT "urn:schemas:httpmail:datereceived", 
"urn:schemas:httpmail:sendername",
"urn:schemas:httpmail:subject"
FROM scope('shallow traversal of ') WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False


In the code, replace the sUser, sExchangeServer and sFolder vars, add a web content webpart and paste the code inside.

<script language=javascript>
 
var sUser = "USERNAME";
var sExchangeServer = "http://SERVER";
var sFolder = "FOLDER";
 
var xmlHttpReq;
 
function getMessages()
{
   var sURL = sExchangeServer + "/exchange/" + sUser + "/" + sFolder;
    
    if (sUser!="" && sURL!="")
    {
      xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");  
    
      xmlHttpReq.open("SEARCH", sURL, true);
      xmlHttpReq.setRequestHeader("Content-type:", "text/xml");
      xmlHttpReq.setRequestHeader("Depth", "1");
     
      xmlHttpReq.onReadyStateChange = checkState;
     
      // Our webDav query
      var sDavQuery = 'SELECT "urn:schemas:httpmail:datereceived", ' +
                              '"urn:schemas:httpmail:sendername", ' +
                              '"urn:schemas:httpmail:subject" ' +
                           ' FROM scope(\'shallow traversal of "' + sURL + '"\' )' +
                           ' WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False ';
 
      // The request package                           
      var sSearchRequest = "<?xml version='1.0' ?>" +
                           "<a:searchrequest xmlns:a='DAV:'><a:sql>" + 
                                 sDavQuery +     
                           "</a:sql></a:searchrequest>";
      
      // Max results
      xmlHttpReq.SetRequestHeader("Range", "rows=0-4");
    
      xmlHttpReq.Send(sSearchRequest);
    }
}
 
function checkState()
{
  if (xmlHttpReq.readyState == 4)
  { 
     var xml = xmlHttpReq.responseXML.documentElement;
    
     // Parse xml - table to present results 
     var xmlResults = xml.getElementsByTagName('a:prop');
        
     var domTableResults = document.createElement('TABLE');
        
     domTableResults.setAttribute('cellPadding',5);
        
     var tmp = document.createElement('TBODY');
        
     domTableResults.appendChild(tmp);
     var domTableRow = document.createElement('TR');
     domTableRow.setAttribute('class','ms-TPHeader;');
        
     // Table header
     for (j=0;j<xmlResults[0].childNodes.length;j++)
     {
        if (xmlResults[0].childNodes[j].nodeType != 1) 
            continue;
        
        var container = document.createElement('TH');
        var theData = document.createTextNode(xmlResults[0].childNodes[j].nodeName);
        
        container.appendChild(theData);
        domTableRow.appendChild(container);
     }
    
     tmp.appendChild(domTableRow);
        
     // Table rows
     for (i=0;i<xmlResults.length;i++)
     {
        var domTableRow = document.createElement('TR');
        domTableRow.setAttribute('class','ms-WPBody;');
            
        for (j=0;j<xmlResults[i].childNodes.length;j++)
        {
            if (xmlResults[i].childNodes[j].nodeType != 1) 
            continue;
            
          var container = document.createElement('TD');
          var theData = document.createTextNode(xmlResults[i].childNodes[j].firstChild.nodeValue);
                
          container.appendChild(theData);
          domTableRow.appendChild(container);
        }
            
        tmp.appendChild(domTableRow);
     }
    
     document.getElementById('divOutput').appendChild(domTableResults);
  }
}
getMessages();
</script>
<div id='divOutput'></div>

 

Comments (1)

SharePoint - csegRollUp 3.1 (the sharepoint aggregator)

Jan 24 2006 by csegura @ 22:29
 

csegRollUp 3.1a

* Fixes

    - Queries with fields that contains spaces
    - Variables in caml queries
    - Other minor bugs

* Improvements (awaited :-))

    - Now there is a new property "From top level" where you can specify the starting point from which the csegrollup would gather the information, this url can be a site or a portal area. The format is an Url format (http://sever/sites/site or http://server/area), Now you can use csegRollUp in an area and rollup content from sites in other areas or others urls, also you can use csegRollUp in a site/subsite and agregate content from a top site.

  csegRollUp31a.zip (75,44 KB)

Comments (31)

SharePoint - La Semana

Jan 22 2006 by csegura @ 22:03

* Via Mart Muller este truco para mover un sitio de sharepoint a otro servidor

* Via ScottGu una utilidad escrita por Cristian Civera para examinar el viewstate en el servidor local. Imprescindible para debugear nuestra páginas asp.net 2.0

* Via Chris Crowe las utilidades de IIS han sido actualizadas, Debug Diagnostics, Trace Diag.

  (x86) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=9BFA49BC-376B-4A54-95AA-73C9156706E7&displaylang=en

  (x64) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=7e42b310-b2d1-496b-8005-9d91782b9995&DisplayLang=en

  (ia64) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=13c1c5e5-592c-45bc-b5bb-c486b43eb539&DisplayLang

 

* Via Mart Muller nos cuenta que su colega Ferry ha hecho una estupenda biblioteca de símbolos para maquetar sitios de sharepoint en Visio, Descargar aquí.

 

* Microsoft Downloads, snippets para VSTO 2005

Comments (0)