Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Dec 12, 2014
1 parent 52519e9 commit 3905efe
Show file tree
Hide file tree
Showing 93 changed files with 1,485 additions and 558 deletions.
6 changes: 6 additions & 0 deletions core/controllers/ApikeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@
/** Apikey controller for Web Api */
class ApikeyController extends AppController
{
/** @var array */
public $_models = array('User', 'Userapi');

/** @var array */
public $_forms = array('Apikey');

/** @var array */
public $_components = array('Date');

/**
* Configuration action for a user's api keys
*
* @param userId The id of the user to display
* @throws Zend_Exception
*/
public function usertabAction()
{
Expand Down
1 change: 1 addition & 0 deletions core/controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ public function getelementinfoAction()
* @param type The type of the resource: (folder | item)
* @return JSON object with the "policy" field set to the max policy on the resource.
* Throws exception if the user has no access to the resource
* @throws Zend_Exception
*/
public function getmaxpolicyAction()
{
Expand Down
3 changes: 3 additions & 0 deletions core/controllers/CommunityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ public function deleteAction()
* Dialog for inviting a user to a community
*
* @param communityId Id of the community to invite into. Write permission required.
* @throws Zend_Exception
*/
public function invitationAction()
{
Expand Down Expand Up @@ -536,6 +537,7 @@ public function addusertogroupAction()
* @param [userId] Id of the user to invite. If not passed, must pass email parameter
* @param [email] Email of the user to invite. If not passed, must pass userId parameter.
* If no such user exists, sends an email inviting the user to register and join the group.
* @throws Zend_Exception
*/
public function sendinvitationAction()
{
Expand Down Expand Up @@ -839,6 +841,7 @@ public function removeuserfromgroupAction()
* Requires moderator or admin permission on the community
*
* @param communityId The id of the community
* @throws Zend_Exception
*/
public function selectgroupAction()
{
Expand Down
15 changes: 13 additions & 2 deletions core/controllers/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
*/
class DownloadController extends AppController
{
/** @var array */
public $_models = array('Folder', 'Item', 'Community', 'User', 'Bitstream');
public $_daos = array();

/** @var array */
public $_components = array('DownloadBitstream');

/** index
/**
* Index action.
*
* @param folders = 12-13 (will download a zip of the folder 12 and 13, recursively)
* @param folders = 12, 1-13, 1 (will download a zip of the folder 12 and 13, recursively) // Need testing
Expand All @@ -37,6 +40,7 @@ class DownloadController extends AppController
* @param bitstream = 1 (will download related bitstream)
* @param offset The offset in bytes if downloading a bitstream (defaults to 0)
* @param name Alternate filename when downloading a bitstream (defaults to bitstream name)
* @throws Zend_Exception
*/
public function indexAction()
{
Expand Down Expand Up @@ -223,6 +227,8 @@ public function indexAction()

/**
* Ajax action for determining what action to take based on the size of the requested download.
*
* @throws Zend_Exception
*/
public function checksizeAction()
{
Expand Down Expand Up @@ -288,6 +294,7 @@ public function checksizeAction()
* download/item/<item_id>/...
* Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
* if the content-disposition header is ignored by the user agent.
* @throws Zend_Exception
*/
public function itemAction()
{
Expand All @@ -304,6 +311,8 @@ public function itemAction()
* download/folder/<folder_id>/...
* Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
* if the content-disposition header is ignored by the user agent.
*
* @throws Zend_Exception
*/
public function folderAction()
{
Expand All @@ -320,6 +329,8 @@ public function folderAction()
* download/bitstream/<bitstream_id>/...
* Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
* if the content-disposition header is ignored by the user agent.
*
* @throws Zend_Exception
*/
public function bitstreamAction()
{
Expand Down
2 changes: 2 additions & 0 deletions core/controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ public function checksharedAction()
* @param metadatatype
* @param element
* @param qualifier
* @throws Zend_Exception
*/
public function getmetadatavalueexistsAction()
{
Expand Down Expand Up @@ -613,6 +614,7 @@ public function getmetadatavalueexistsAction()
* otherwise the request produces no output.
*
* @param itemId The item whose thumbnail you wish to download
* @throws Zend_Exception
*/
public function thumbnailAction()
{
Expand Down
1 change: 1 addition & 0 deletions core/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ public function deletedialogAction()
* @param [lastName] User's last name
* @param [password] User's password
* @param [password2] User's password retyped
* @throws Zend_Exception
*/
public function emailregisterAction()
{
Expand Down
15 changes: 9 additions & 6 deletions core/controllers/components/ApihelperComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ public function listResourcePermissions($policyStatus, $userPolicies, $groupPoli
*
* @param id the group to add the user to
* @param user_id the user to add to the group
* @return an array of (groupModel, groupDao, groupUserDao)
* @return array an array of (groupModel, groupDao, groupUserDao)
* @throws Exception
*/
public function validateGroupUserChangeParams($args)
{
Expand All @@ -417,7 +418,7 @@ public function validateGroupUserChangeParams($args)
$communityModel = MidasLoader::loadModel('Community');
if (!$communityModel->policyCheck($group->getCommunity(), $userDao, MIDAS_POLICY_ADMIN)
) {
throw new Zend_Exception("Community Admin permissions required.", MIDAS_INVALID_POLICY);
throw new Exception("Community Admin permissions required.", MIDAS_INVALID_POLICY);
}

$groupUserId = $args['user_id'];
Expand Down Expand Up @@ -451,8 +452,9 @@ public function checkMetadataTypeOrName(&$args, &$metadataModel)
* helper method to validate passed in community privacy status params and
* map them to valid community privacy codes.
*
* @param string $privacyStatus , should be 'Private' or 'Public'
* @return valid community privacy code
* @param string $privacyStatus should be 'Private' or 'Public'
* @return int valid community privacy code
* @throws Exception
*/
public function getValidCommunityPrivacyCode($privacyStatus)
{
Expand All @@ -472,8 +474,9 @@ public function getValidCommunityPrivacyCode($privacyStatus)
* helper method to validate passed in community can join status params and
* map them to valid community can join codes.
*
* @param string $canjoinStatus , should be 'Everyone' or 'Invitation'
* @return valid community canjoin code
* @param string $canjoinStatus should be 'Everyone' or 'Invitation'
* @return int valid community canjoin code
* @throws Exception
*/
public function getValidCommunityCanjoinCode($canjoinStatus)
{
Expand Down
34 changes: 25 additions & 9 deletions core/models/base/CommunityInvitationModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** ItemRevisionModelBase */
class CommunityInvitationModelBase extends AppModel
{
/** Constructor */
/** Constructor. */
public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -57,11 +57,13 @@ public function __construct()
}

/**
* Create an invitation record for the user into the given group
* Create an invitation record for the user into the given group.
*
* @param groupDao The group to invite the user to
* @param userDao The user performing the invitation (typically the session user)
* @param invitedUserDao The user being invited to the group
* @param GroupDao $groupDao The group to invite the user to
* @param UserDao $userDao The user performing the invitation (typically the session user)
* @param UserDao $invitedUserDao The user being invited to the group
* @return false|CommunityInvitationDao
* @throws Zend_Exception
*/
public function createInvitation($groupDao, $userDao, $invitedUserDao)
{
Expand Down Expand Up @@ -92,7 +94,14 @@ public function createInvitation($groupDao, $userDao, $invitedUserDao)
return $invitationDao;
}

/** is user invited */
/**
* Is user invited?
*
* @param CommunityDao $communityDao
* @param UserDao $userDao
* @param bool $returnDao
* @return bool|CommunityInvitationDao
*/
public function isInvited($communityDao, $userDao, $returnDao = false)
{
if ($userDao == null) {
Expand All @@ -112,11 +121,18 @@ public function isInvited($communityDao, $userDao, $returnDao = false)
return false;
}

/** remove invitation */
/**
* Remove invitation.
*
* @param CommunityDao $communityDao
* @param UserDao $userDao
* @return bool
* @throws Zend_Exception
*/
public function removeInvitation($communityDao, $userDao)
{
if ($userDao == null) {
return;
return false;
}
$invitations = $userDao->getInvitations();
foreach ($invitations as $invitation) {
Expand All @@ -133,6 +149,6 @@ public function removeInvitation($communityDao, $userDao)
}
}

return;
return false;
}
}
7 changes: 4 additions & 3 deletions core/models/base/CommunityModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@ public function countBitstreams($communityDao, $userDao = null)
* which should be one of MIDAS_COMMUNITY_PUBLIC, MIDAS_COMMUNITY_PRIVATE.
*
* @param CommunityDao $communityDao
* @param type $privacyCode
* @param type $userDao
* @param int $privacyCode
* @param UserDao $userDao
* @throws Zend_Exception
*/
public function setPrivacy($communityDao, $privacyCode, $userDao)
{
Expand All @@ -384,7 +385,7 @@ public function setPrivacy($communityDao, $privacyCode, $userDao)
}
if ($privacyCode === false || ($privacyCode != MIDAS_COMMUNITY_PUBLIC && $privacyCode != MIDAS_COMMUNITY_PRIVATE)
) {
throw new Exception('invalid value for privacyCode: '.$privacyCode);
throw new Zend_Exception('invalid value for privacyCode: '.$privacyCode);
}

$feedModel = MidasLoader::loadModel('Feed');
Expand Down
18 changes: 12 additions & 6 deletions core/models/base/ItemModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,10 @@ public function addReadonlyPolicy($itemdao, $folderdao)
* input userDao parameter (who run this operation) and access policy is based on
* the input folderDao parameter (destination folder)
*
* @param ItemDao $itemDao the item to be duplicated
* @param UserDao $userDao the user who run this operation
* @param FolderDao $folderDao destination folder
* @param ItemDao $itemDao the item to be duplicated
* @param UserDao $userDao the user who run this operation
* @param FolderDao $folderDao destination folder
* @return ItemDao
* @throws Zend_Exception on invalid input parameters (itemDao, userDao and folderDao)
*/
public function duplicateItem($itemDao, $userDao, $folderDao)
Expand Down Expand Up @@ -403,9 +404,12 @@ public function incrementDownloadCount($itemdao)
Zend_Registry::get('notifier')->callback("CALLBACK_CORE_PLUS_ONE_DOWNLOAD", array('item' => $itemdao));
}

/** Add a revision to an item
/**
* Add a revision to an item.
*
* @return void
* @param ItemDao $itemdao
* @param ItemRevisionDao $revisiondao
* @throws Zend_Exception
*/
public function addRevision($itemdao, $revisiondao)
{
Expand Down Expand Up @@ -435,7 +439,9 @@ public function addRevision($itemdao, $revisiondao)
* Delete an itemrevision from an item, will reduce all other
* itemrevision revision numbers appropriately.
*
* @return void
* @param ItemDao $itemdao
* @param ItemRevisionDao $revisiondao
* @throws Zend_Exception
*/
public function removeRevision($itemdao, $revisiondao)
{
Expand Down
7 changes: 6 additions & 1 deletion core/models/pdo/ActivedownloadModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
*/
class ActivedownloadModel extends ActivedownloadModelBase
{
/** Check whether an active download exists for the given ip */
/**
* Check whether an active download exists for the given IP address.
*
* @param string $ip
* @return false|ActivedownloadDao
*/
public function getByIp($ip)
{
$sql = $this->database->select()->setIntegrityCheck(false)->from(array('a' => 'activedownload'))->where(
Expand Down
17 changes: 11 additions & 6 deletions core/models/pdo/AssetstoreModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@
*/
class AssetstoreModel extends AssetstoreModelBase
{
/** get All */
/**
* Get all.
*
* @return array
*/
public function getAll()
{
return $this->database->getAll('Assetstore');
}

/**
* Move all bitstreams from one assetstore to another
* Move all bitstreams from one asset store to another
*
* @param srcAssetstore The source assetstore
* @param dstAssetstore The destination assetstore
* @param [progressDao] Progress dao for asynchronous updating
* @param AssetstoreDao $srcAssetstore The source asset store
* @param AssetstoreDao $dstAssetstore The destination asset store
* @param null|ProgressDao $progressDao Progress dao for asynchronous updating
* @throws Zend_Exception
*/
public function moveBitstreams($srcAssetstore, $dstAssetstore, $progressDao = null)
{
Expand Down Expand Up @@ -91,7 +96,7 @@ public function moveBitstreams($srcAssetstore, $dstAssetstore, $progressDao = nu
}
}

// Update the assetstore id on the bitstream record once it has been moved
// Update the asset store id on the bitstream record once it has been moved
$bitstream->setAssetstoreId($dstAssetstore->getKey());
$bitstreamModel->save($bitstream);
}
Expand Down
Loading

0 comments on commit 3905efe

Please sign in to comment.