本文整理汇总了PHP中Folder::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::setType方法的具体用法?PHP Folder::setType怎么用?PHP Folder::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::setType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNotDeletableForUser
/**
* @param sfGuardUser $user
* @param $type
* @param $create_if_not_exists
* @return mixed
*/
public function getNotDeletableForUser(sfGuardUser $user, $type, $create_if_not_exists = true)
{
$folder = $this->createQuery('f')->whereIn('f.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($user))->andWhere('f.deletable = ?', 0)->andWhere('f.type = ?', $type)->fetchOne();
if (!$folder && $create_if_not_exists) {
$folder = new Folder();
$folder->setName('Default');
$folder->setUserId($user->getId());
$folder->setDeletable(0);
$folder->setType($type);
$folder->save();
}
return $folder;
}
示例2: executeNewFolder
public function executeNewFolder(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$folder = new Folder();
$folder->setName('New ' . InterfaceLabelTable::getInstance()->get($this->getuser()->getGuardUser(), InterfaceLabelTable::FOLDER_TYPE));
$folder->setUser($this->getUser()->getGuardUser());
$folder->setType(Folder::TYPE_ROADMAP);
if (!Folder::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_ROADMAP, false)) {
$folder->setDeletable(false);
}
$folder->save();
// Create log
$log = new Log();
$log->injectDataAndPersist($folder, $this->getUser()->getGuardUser(), array('action' => 'new'));
return $this->renderText(json_encode($folder->getRowData()));
}
示例3: handleRoadmaps
public function handleRoadmaps()
{
$default_folders = array();
$conn = Doctrine_Manager::getInstance()->connection();
$roadmaps = $conn->execute("SELECT id, user_id from `roadmap` WHERE folder_id is NULL")->fetchAll();
foreach ($roadmaps as $roadmap) {
if (!array_key_exists($roadmap['user_id'], $default_folders)) {
$folder = $conn->execute("SELECT id from `folder` WHERE `user_id` = :user_id and `type` = '" . Folder::TYPE_ROADMAP . "' and `deletable` = 0 LIMIT 1;", array(':user_id' => $roadmap['user_id']))->fetchAll();
if (count($folder)) {
$default_folders[$roadmap['user_id']] = $folder[0]['id'];
} else {
$folder = new Folder();
$folder->setName('Default');
$folder->setUserId($roadmap['user_id']);
$folder->setDeletable(0);
$folder->setType(Folder::TYPE_ROADMAP);
$folder->save();
$default_folders[$roadmap['user_id']] = $folder->getId();
}
}
$conn->execute("UPDATE `roadmap` SET `folder_id` = :folder_id WHERE id = :id", array(':folder_id' => $default_folders[$roadmap['user_id']], ':id' => $roadmap['id']));
}
}
示例4: getFolderInfo
/**
* Get Folder Info
*
* @param folderId - required -
* The id of the folder.
* @param includeFiles - optional -
* Default = true. If true, the API returns
* info about all the files in the specified folder, at this folder level only.
* @param includeFolders - optional -
* Default = true. If true, the API returns info about all
* the sub folders, at this folder level only
* @return The Folder object. If the operation was successful, the object contains the folder info, if not, the object
* contains the error code and message.
*/
public function getFolderInfo($folderId, $includeFiles = '', $includeFolders = '')
{
$parameters = array();
if ($includeFiles !== '') {
$parameters['includeFiles'] = $includeFiles;
}
if ($includeFolders !== '') {
$parameters['includeFolders'] = $includeFolders;
}
$urld = 'dpi/v1/folder/' . $folderId;
$this->response = $this->restTransportInstance->sendRequest($urld, $parameters, self::HTTP_GET, $this->authToken);
$responseBody = simplexml_load_string($this->response);
$returnObject = new Folder();
if ($responseBody === false) {
$errorCode = 'N/A';
$errorMessage = 'The server has encountered an error, please try again.';
$errorObject = new ErrorStatus($errorCode, $errorMessage);
$returnObject->setErrorStatus($errorObject);
} else {
$errorStatus = $responseBody->errorStatus;
if (empty($errorStatus)) {
$returnObject->setRevision((string) $responseBody->attributes()->revision);
$returnObject->setId((string) $responseBody->attributes()->id);
$returnObject->setCreatedOn((string) $responseBody->createdOn);
$returnObject->setName((string) $responseBody->name);
$returnObject->setParentId((string) $responseBody->parentid);
$returnObject->setReadable((string) $responseBody->readable);
$returnObject->setSize((string) $responseBody->size);
$returnObject->setType((string) $responseBody->type);
$returnObject->setUpdatedOn((string) $responseBody->updatedOn);
$returnObject->setWritable((string) $responseBody->writeable);
$returnObject->setCurrentUsage((string) $responseBody->currentUsage);
$returnObject->setStorageQuota((string) $responseBody->storageQuota);
$fileCount = (string) $responseBody->fileCount;
$returnObject->setFileCount($fileCount);
$folderCount = (string) $responseBody->folderCount;
$returnObject->setFolderCount($folderCount);
if ($includeFiles) {
$filesTag = $responseBody->files;
if (!empty($filesTag)) {
$allFiles = $responseBody->files->children();
$files = array();
if (!empty($allFiles)) {
foreach ($allFiles as $currentFile) {
$file = new File();
$file->setRevision((string) $currentFile->attributes()->revision);
$file->setId((string) $currentFile->attributes()->id);
$file->setCreatedOn((string) $currentFile->createdOn);
$file->setName((string) $currentFile->name);
$file->setParentId((string) $currentFile->parentid);
$file->setSize((string) $currentFile->size);
array_push($files, $file);
}
$returnObject->setFiles($files);
}
}
}
if ($includeFolders) {
$foldersTag = $responseBody->folders;
if (!empty($foldersTag)) {
$allFolders = $responseBody->folders->children();
$folders = array();
if (!empty($allFolders)) {
foreach ($allFolders as $currentFolder) {
$folder = new Folder();
$folder->setRevision((string) $currentFolder->attributes()->revision);
$folder->setId((string) $currentFolder->attributes()->id);
$folder->setCreatedOn((string) $currentFolder->createdOn);
$folder->setCurrentUsage((string) $currentFolder->currentUsage);
$folder->setFileCount((string) $currentFolder->fileCount);
$folder->setFolderCount((string) $currentFolder->folderCount);
$folder->setName((string) $currentFolder->name);
$folder->setParentId((string) $currentFolder->parentid);
$folder->setReadable((string) $currentFolder->readable);
$folder->setSize((string) $currentFolder->size);
$folder->setType((string) $currentFolder->type);
$folder->setUpdatedOn((string) $currentFolder->updatedOn);
$folder->setWritable((string) $currentFolder->writeable);
$folder->setOwnedByUser((string) $currentFolder->ownedByUser);
array_push($folders, $folder);
}
$returnObject->setFolders($folders);
}
}
}
} else {
//.........这里部分代码省略.........