/**
  * Get a SharePoint User by Account
  *
  * @access  public
  * @param   SPSite $site    SharePoint Site object
  * @param   string $account SharePoint User account
  * @param   array  $extra   Extra properties to map
  * @throws  SPException
  * @return  SPUser
  */
 public static function getByAccount(SPSite $site, $account, array $extra = [])
 {
     $json = $site->request('_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)', ['headers' => ['Authorization' => 'Bearer ' . $site->getSPAccessToken(), 'Accept' => 'application/json'], 'query' => ['@v' => "'" . $account . "'"]], 'POST');
     return new static($site, $json, $extra);
 }
 /**
  * Create a SharePoint List
  *
  * @static
  * @access  public
  * @param   SPSite $site       SharePoint Site
  * @param   array  $properties SharePoint List properties (Title, Description, ...)
  * @param   array  $settings   Instantiation settings
  * @throws  SPException
  * @return  SPList
  */
 public static function create(SPSite $site, array $properties, array $settings = [])
 {
     $properties = array_replace_recursive(['BaseTemplate' => static::TPL_DOCUMENTLIBRARY], $properties, ['odata.type' => 'SP.List']);
     $body = json_encode($properties);
     $json = $site->request('_api/web/Lists', ['headers' => ['Authorization' => 'Bearer ' . $site->getSPAccessToken(), 'Accept' => 'application/json', 'X-RequestDigest' => (string) $site->getSPFormDigest(), 'Content-type' => 'application/json', 'Content-length' => strlen($body)], 'query' => ['$expand' => 'RootFolder'], 'body' => $body], 'POST');
     return new static($site, $json, $settings);
 }
 /**
  * Get SubFolders of a SharePoint Folder
  *
  * @static
  * @access  public
  * @param   SPSite $site        SharePoint Site
  * @param   string $relativeUrl SharePoint Folder relative URL
  * @param   array  $settings    Instantiation settings
  * @throws  SPException
  * @return  array
  */
 public static function getSubFolders(SPSite $site, $relativeUrl, array $settings = [])
 {
     $json = $site->request("_api/web/GetFolderByServerRelativeUrl('" . $relativeUrl . "')/Folders", ['headers' => ['Authorization' => 'Bearer ' . $site->getSPAccessToken(), 'Accept' => 'application/json'], 'query' => ['$expand' => 'ListItemAllFields/ParentList,Properties']]);
     $folders = [];
     foreach ($json['value'] as $subFolder) {
         // skip System Folders
         if (!static::isSystemFolder($subFolder['Name'])) {
             $folders[$subFolder['UniqueId']] = new static($site, $subFolder, $settings);
         }
     }
     return $folders;
 }
Example #4
0
 /**
  * Permanently delete a SharePoint RecycleBin Item
  *
  * @throws  \Impensavel\Spoil\Exception\SPRuntimeException
  * @return  bool
  */
 public function delete()
 {
     $this->site->request("_api/web/RecycleBin('" . $this->guid . "')/deleteObject()", ['headers' => ['Authorization' => 'Bearer ' . $this->site->getSPAccessToken(), 'Accept' => 'application/json']], 'POST');
     return true;
 }