• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MidasLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中MidasLoader的典型用法代码示例。如果您正苦于以下问题:PHP MidasLoader类的具体用法?PHP MidasLoader怎么用?PHP MidasLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MidasLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: createThumbnail

 /**
  * Create a thumbnail bitstream in the provided assetstore using the
  * passed tempThumbnailFile, which will be moved to the assetstore.
  *
  * @return The bitstream dao that was created for the thumbnail
  */
 public function createThumbnail($assetstore, $tempThumbnailFile)
 {
     /** @var BitstreamDao $bitstreamDao */
     $bitstreamDao = MidasLoader::newDao('BitstreamDao');
     $md5 = md5_file($tempThumbnailFile);
     $bitstreamDao->setName('thumbnail.jpeg');
     $bitstreamDao->setItemrevisionId(-1);
     //-1 indicates this does not belong to any revision
     $bitstreamDao->setMimetype('image/jpeg');
     $bitstreamDao->setSizebytes(filesize($tempThumbnailFile));
     $bitstreamDao->setDate(date('Y-m-d H:i:s'));
     $bitstreamDao->setChecksum($md5);
     $existing = $this->getByChecksum($md5);
     if ($existing) {
         unlink($tempThumbnailFile);
         $bitstreamDao->setPath($existing->getPath());
         $bitstreamDao->setAssetstoreId($existing->getAssetstoreId());
     } else {
         $path = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . $md5;
         $fullpath = $assetstore->getPath() . '/' . $path;
         $currentdir = $assetstore->getPath() . '/' . substr($md5, 0, 2);
         $this->_createAssetstoreDirectory($currentdir);
         $currentdir .= '/' . substr($md5, 2, 2);
         $this->_createAssetstoreDirectory($currentdir);
         rename($tempThumbnailFile, $fullpath);
         $bitstreamDao->setAssetstoreId($assetstore->getKey());
         $bitstreamDao->setPath($path);
     }
     $this->save($bitstreamDao);
     return $bitstreamDao;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:37,代码来源:BitstreamModelBase.php


示例2: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, $config->get('dcmj2pnm', DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, $config->get('dcmftest', DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, $config->get('dcmdictpath', DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->dcmj2pnm);
         unset($config->global->dcmftest);
         unset($config->global->dcmdictpath);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:1.1.0.php


示例3: postInstall

 /** Post database install. */
 public function postInstall()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $settingModel->setConfig(MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_KEY, MIDAS_SIZEQUOTA_DEFAULT_USER_QUOTA_DEFAULT_VALUE, $this->moduleName);
     $settingModel->setConfig(MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_KEY, MIDAS_SIZEQUOTA_DEFAULT_COMMUNITY_QUOTA_DEFAULT_VALUE, $this->moduleName);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:InstallScript.php


示例4: generateToken

 /**
  * Generate an upload token that will act as the authentication token for the upload.
  * This token is the filename of a unique file which will be placed under the
  * directory specified by the dirname parameter, which should be used to ensure that
  * the user can only write into a certain logical space.
  *
  * @param array $args
  * @param string $dirname
  * @return array
  * @throws Exception
  */
 public function generateToken($args, $dirname = '')
 {
     if (!array_key_exists('filename', $args)) {
         throw new Exception('Parameter filename is not defined', MIDAS_HTTPUPLOAD_FILENAME_PARAM_UNDEFINED);
     }
     $tempDirectory = UtilityComponent::getTempDirectory();
     $dir = $dirname === '' ? '' : '/' . $dirname;
     $dir = $tempDirectory . $dir;
     if (!file_exists($dir)) {
         if (!mkdir($dir, 0777, true)) {
             throw new Exception('Failed to create temporary upload dir', MIDAS_HTTPUPLOAD_TMP_DIR_CREATION_FAILED);
         }
     }
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     $uniqueIdentifier = $randomComponent->generateString(64);
     if ($dirname != '') {
         $uniqueIdentifier = $dirname . '/' . $uniqueIdentifier;
     }
     $path = $tempDirectory . '/' . $uniqueIdentifier;
     if (file_exists($path)) {
         throw new Exception('Failed to generate upload token', MIDAS_HTTPUPLOAD_UPLOAD_TOKEN_GENERATION_FAILED);
     }
     if (touch($path) === false) {
         mkdir($path, 0777, true);
         $uniqueIdentifier .= '/';
     }
     return array('token' => $uniqueIdentifier);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:40,代码来源:HttpuploadComponent.php


示例5: createPolicy

 /** create a policy
  * @return FeedpolicyuserDao
  */
 public function createPolicy($user, $feed, $policy)
 {
     if (!$user instanceof UserDao) {
         throw new Zend_Exception('Should be a user.');
     }
     if (!$feed instanceof FeedDao) {
         throw new Zend_Exception('Should be a feed.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$user->saved && !$feed->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     if ($this->getPolicy($user, $feed) !== false) {
         $this->delete($this->getPolicy($user, $feed));
     }
     /** @var FeedpolicyuserDao $policyUser */
     $policyUser = MidasLoader::newDao('FeedpolicyuserDao');
     $policyUser->setUserId($user->getUserId());
     $policyUser->setFeedId($feed->getFeedId());
     $policyUser->setPolicy($policy);
     $this->save($policyUser);
     return $policyUser;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:FeedpolicyuserModelBase.php


示例6: scheduleOrCancelSendReportJob

 /**
  * Schedule or cancel the send report job.
  *
  * @param bool $schedule schedule the job if true, cancel the job if false
  * @param null|UserDao $userDao user scheduling the job
  *
  * @throws Zend_Exception
  */
 public function scheduleOrCancelSendReportJob($schedule, $userDao = null)
 {
     /** @var Scheduler_JobModel $jobModel */
     $jobModel = MidasLoader::loadModel('Job', 'scheduler');
     $jobDaos = $jobModel->getJobsByTask('TASK_STATISTICS_SEND_REPORT');
     $reportJobDao = false;
     foreach ($jobDaos as $jobDao) {
         if ($jobDao->getTask() === 'TASK_STATISTICS_SEND_REPORT') {
             $reportJobDao = $jobDao;
             break;
         }
     }
     if ($schedule) {
         if ($reportJobDao === false) {
             /** @var Scheduler_JobDao $reportJobDao */
             $reportJobDao = MidasLoader::newDao('JobDao', 'scheduler');
             $reportJobDao->setTask('TASK_STATISTICS_SEND_REPORT');
             $reportJobDao->setPriority(1);
             $reportJobDao->setRunOnlyOnce(0);
             $reportJobDao->setFireTime(date('Y-m-d', strtotime('+1 day' . date('Y-m-d H:i:s'))) . ' 01:00:00');
             $reportJobDao->setTimeInterval(86400);
             $reportJobDao->setStatus(SCHEDULER_JOB_STATUS_TORUN);
             $reportJobDao->setCreatorId($this->userSession->Dao->getKey());
             $reportJobDao->setParams(JsonComponent::encode(array()));
             if (!is_null($userDao)) {
                 $reportJobDao->setCreatorId($userDao->getKey());
             }
             $jobModel->save($reportJobDao);
         }
     } else {
         if ($reportJobDao !== false) {
             $jobModel->delete($reportJobDao);
         }
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:43,代码来源:AdminComponent.php


示例7: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $piwikUrl = isset($config->piwik->url) ? $config->piwik->url : STATISTICS_PIWIK_URL_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, $piwikUrl, $this->moduleName);
         $piwikId = isset($config->piwik->id) ? $config->piwik->id : STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, $piwikId, $this->moduleName);
         $piwikApiKey = isset($config->piwik->apikey) ? $config->piwik->apikey : STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, $piwikApiKey, $this->moduleName);
         $ipInfoDbApiKey = isset($config->ipinfodb->apikey) ? $config->ipinfodb->apikey : STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, $ipInfoDbApiKey, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, $config->get('report', STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->piwik->url);
         unset($config->global->piwik->id);
         unset($config->global->piwik->pikey);
         unset($config->global->ipinfodb->apikey);
         unset($config->global->report);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, STATISTICS_PIWIK_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:35,代码来源:1.1.0.php


示例8: itemrevisionGet

 /**
  * Fetch the information about an ItemRevision.
  *
  * @path /itemrevision/{id}
  * @http GET
  * @param id The id of the ItemRevision
  * @return ItemRevision object
  *
  * @param array $args parameters
  * @throws Exception
  */
 public function itemrevisionGet($args)
 {
     /** @var ApihelperComponent $apihelperComponent */
     $apihelperComponent = MidasLoader::loadComponent('Apihelper');
     $apihelperComponent->validateParams($args, array('id'));
     $apihelperComponent->requirePolicyScopes(array(MIDAS_API_PERMISSION_SCOPE_READ_DATA));
     $userDao = $apihelperComponent->getUser($args);
     $itemrevision_id = $args['id'];
     /** @var ItemRevisionModel $itemRevisionModel */
     $itemRevisionModel = MidasLoader::loadModel('ItemRevision');
     $itemRevision = $itemRevisionModel->load($itemrevision_id);
     /** @var ItemModel $itemModel */
     $itemModel = MidasLoader::loadModel('Item');
     $item = $itemModel->load($itemRevision->getItemId());
     if ($item === false || !$itemModel->policyCheck($item, $userDao, MIDAS_POLICY_READ)) {
         throw new Exception("This item doesn't exist or you don't have the permissions.", MIDAS_INVALID_POLICY);
     }
     $in = $itemRevision->toArray();
     $out = array();
     $out['id'] = $in['itemrevision_id'];
     $out['item_id'] = $in['item_id'];
     $out['date_created'] = $in['date'];
     $out['date_updated'] = $in['date'];
     // fix this
     $out['changes'] = $in['changes'];
     $out['user_id'] = $in['user_id'];
     $out['license_id'] = $in['license_id'];
     $out['uuid'] = $in['uuid'];
     $out['bitstreams'] = array_map(array($this, 'getBitstreamId'), $itemRevision->getBitstreams());
     return $out;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:42,代码来源:ApiitemrevisionComponent.php


示例9: createPolicy

 /** @return ItempolicyuserDao */
 public function createPolicy($user, $item, $policy)
 {
     if (!$user instanceof UserDao) {
         throw new Zend_Exception('Should be a user.');
     }
     if (!$item instanceof ItemDao) {
         throw new Zend_Exception('Should be an item.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$user->saved && !$item->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     $policyUser = $this->getPolicy($user, $item);
     if ($policyUser !== false) {
         $this->delete($policyUser);
     }
     /** @var ItempolicyuserDao $policyUser */
     $policyUser = MidasLoader::newDao('ItempolicyuserDao');
     $policyUser->setUserId($user->getUserId());
     $policyUser->setItemId($item->getItemId());
     $policyUser->setPolicy($policy);
     $this->save($policyUser);
     return $policyUser;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:27,代码来源:ItempolicyuserModelBase.php


示例10: extract

 /**
  * Extract the dicom metadata from a revision.
  *
  * @param item the id of the item to be extracted
  * @return the id of the revision
  */
 public function extract($args)
 {
     /** @var ApihelperComponent $ApihelperComponent */
     $ApihelperComponent = MidasLoader::loadComponent('Apihelper');
     $ApihelperComponent->renameParamKey($args, 'item', 'id');
     return $this->_callModuleApiMethod($args, 'extract', 'item');
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:13,代码来源:ApiComponent.php


示例11: testDailyTotals

 /**
  * Test that we receive the correct daily totals from our model.
  */
 public function testDailyTotals()
 {
     /** @var Statistics_DownloadModel $downloadModel */
     $downloadModel = MidasLoader::loadModel('Download', 'statistics');
     // Add 50 downloads 3 days ago
     for ($i = 0; $i < 50; ++$i) {
         /** @var Statistics_DownloadDao $dao */
         $dao = MidasLoader::newDao('DownloadDao', 'statistics');
         $dao->setItemId(7);
         $dao->setIpLocationId(1);
         $dao->setDate(date('Y-m-d 01:' . str_pad($i, 2, '0', STR_PAD_LEFT) . ':00', strtotime('-3 day')));
         $downloadModel->save($dao);
     }
     // Add 20 downloads 2 days ago
     for ($i = 0; $i < 20; ++$i) {
         /** @var Statistics_DownloadDao $dao */
         $dao = MidasLoader::newDao('DownloadDao', 'statistics');
         $dao->setItemId(7);
         $dao->setIpLocationId(1);
         $dao->setDate(date('Y-m-d 01:' . str_pad($i, 2, '0', STR_PAD_LEFT) . ':00', strtotime('-2 day')));
         $downloadModel->save($dao);
     }
     $arrayDownload = $downloadModel->getDailyCounts(array(7), date('Y-m-d H:i:s', strtotime('-20 day' . date('Y-m-d G:i:s'))), date('Y-m-d H:i:s'));
     $this->assertEquals(count($arrayDownload), 2);
     $this->assertEquals($arrayDownload[date('Y-m-d', strtotime('-3 day'))], 50);
     $this->assertEquals($arrayDownload[date('Y-m-d', strtotime('-2 day'))], 20);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:30,代码来源:DownloadModelTest.php


示例12: acquireLock

 /**
  * Call this function to acquire the download lock.
  * This will return false if an active download already exists for
  * this ip address, otherwise it will return the active download
  * lock that was created.
  */
 public function acquireLock()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip .= '_' . $_SERVER['HTTP_X_FORWARDED_FOR'];
     }
     $oldLock = $this->getByIp($ip);
     if ($oldLock !== false) {
         // If an old lock exists but has not been updated in more than 5 minutes, we
         // should release the old lock and create a new one.
         $lastUpdate = strtotime($oldLock->getLastUpdate());
         if (time() > $lastUpdate + 300) {
             $this->delete($oldLock);
         } else {
             return false;
         }
     }
     /** @var ActivedownloadDao $activeDownload */
     $activeDownload = MidasLoader::newDao('ActivedownloadDao');
     $activeDownload->setDateCreation(date('Y-m-d H:i:s'));
     $activeDownload->setLastUpdate(date('Y-m-d H:i:s'));
     $activeDownload->setIp($ip);
     $this->save($activeDownload);
     return $activeDownload;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:31,代码来源:ActivedownloadModelBase.php


示例13: testGetAll

 /** testGetAll */
 public function testGetAll()
 {
     /** @var Packages_PackageModel $packageModel */
     $packageModel = MidasLoader::loadModel('Package', 'packages');
     $daos = $packageModel->getAll();
     $this->assertEquals(1, count($daos));
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:PackageModelTest.php


示例14: createPolicy

 /** create a policy
  * @return FeedpolicygroupDao
  */
 public function createPolicy($group, $feed, $policy)
 {
     if (!$group instanceof GroupDao) {
         throw new Zend_Exception('Should be a group.');
     }
     if (!$feed instanceof FeedDao) {
         throw new Zend_Exception('Should be a feedDao.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$group->saved && !$feed->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     if ($this->getPolicy($group, $feed) !== false) {
         $this->delete($this->getPolicy($group, $feed));
     }
     /** @var FeedpolicygroupDao $policyGroupDao */
     $policyGroupDao = MidasLoader::newDao('FeedpolicygroupDao');
     $policyGroupDao->setGroupId($group->getGroupId());
     $policyGroupDao->setFeedId($feed->getFeedId());
     $policyGroupDao->setPolicy($policy);
     $this->save($policyGroupDao);
     return $policyGroupDao;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:28,代码来源:FeedpolicygroupModelBase.php


示例15: otpLogin

 /**
  * Submit your OTP after calling core login, and you will receive your api token.
  *
  * @param otp The one-time password
  * @param mfaTokenId The id of the temporary MFA token
  * @return The api token
  * @throws Exception
  */
 public function otpLogin($params)
 {
     $this->_checkKeys(array('otp', 'mfaTokenId'), $params);
     /** @var Mfa_ApitokenModel $tempTokenModel */
     $tempTokenModel = MidasLoader::loadModel('Apitoken', 'mfa');
     /** @var Mfa_OtpdeviceModel $otpDeviceModel */
     $otpDeviceModel = MidasLoader::loadModel('Otpdevice', 'mfa');
     /** @var TokenModel $apiTokenModel */
     $apiTokenModel = MidasLoader::loadModel('Token');
     $tempToken = $tempTokenModel->load($params['mfaTokenId']);
     if (!$tempToken) {
         throw new Exception('Invalid MFA token id', -1);
     }
     $apiToken = $apiTokenModel->load($tempToken->getTokenId());
     if (!$apiToken) {
         $tempTokenModel->delete($tempToken);
         throw new Exception('Corresponding api token no longer exists', -1);
     }
     $user = $tempToken->getUser();
     $otpDevice = $otpDeviceModel->getByUser($user);
     if (!$otpDevice) {
         $tempTokenModel->delete($tempToken);
         throw new Exception('User does not have an OTP device', -1);
     }
     $tempTokenModel->delete($tempToken);
     /** @var Mfa_OtpComponent $otpComponent */
     $otpComponent = MidasLoader::loadComponent('Otp', 'mfa');
     if (!$otpComponent->authenticate($otpDevice, $params['otp'])) {
         throw new Exception('Incorrect OTP', -1);
     }
     $token = $apiToken->getToken();
     return array('token' => $token);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:41,代码来源:ApiComponent.php


示例16: rateitemAction

 /**
  * Set a rating on an item.
  *
  * @param itemId The item id to set the rating on
  * @param rating The rating (0-5) to set for the currently logged user. 0 means remove user's rating.
  * @throws Zend_Exception
  */
 public function rateitemAction()
 {
     if (!$this->logged) {
         throw new Zend_Exception('Must be logged in to rate an item');
     }
     $itemId = $this->getParam('itemId');
     if (!isset($itemId) || !$itemId) {
         throw new Zend_Exception('Must set itemId parameter');
     }
     $item = $this->Item->load($itemId);
     if (!$item) {
         throw new Zend_Exception('Not a valid itemId');
     }
     $rating = (int) $this->getParam('rating');
     if ($rating < 0 || $rating > 5) {
         throw new Zend_Exception('Rating must be 0-5');
     }
     $this->disableView();
     $this->disableLayout();
     /** @var Ratings_ItemratingModel $itemRatingModel */
     $itemRatingModel = MidasLoader::loadModel('Itemrating', $this->moduleName);
     $itemRatingModel->setRating($this->userSession->Dao, $item, $rating);
     $info = $itemRatingModel->getAggregateInfo($item);
     $message = $rating == 0 ? 'Rating removed' : 'Rating saved';
     echo JsonComponent::encode(array_merge(array('status' => 'ok', 'message' => $message), $info));
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:33,代码来源:RatingController.php


示例17: createPolicy

 /** create a policy
  * @return FolderpolicygroupDao
  */
 public function createPolicy($group, $folder, $policy)
 {
     if (!$group instanceof GroupDao) {
         throw new Zend_Exception('Should be a group.');
     }
     if (!$folder instanceof FolderDao) {
         throw new Zend_Exception('Should be a folder.');
     }
     if (!is_numeric($policy)) {
         throw new Zend_Exception('Should be a number.');
     }
     if (!$group->saved && !$folder->saved) {
         throw new Zend_Exception('Save the daos first.');
     }
     $policyGroupDao = $this->getPolicy($group, $folder);
     if ($policyGroupDao !== false) {
         $this->delete($policyGroupDao);
     }
     /** @var FolderpolicygroupDao $policyGroupDao */
     $policyGroupDao = MidasLoader::newDao('FolderpolicygroupDao');
     $policyGroupDao->setGroupId($group->getGroupId());
     $policyGroupDao->setFolderId($folder->getFolderId());
     $policyGroupDao->setPolicy($policy);
     $this->save($policyGroupDao);
     if ($policyGroupDao->getGroupId() == MIDAS_GROUP_ANONYMOUS_KEY) {
         $this->computePolicyStatus($folder);
     }
     return $policyGroupDao;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:32,代码来源:FolderpolicygroupModelBase.php


示例18: addDownload

 /** add a download record for the given item */
 public function addDownload($item, $user)
 {
     if (!$item instanceof ItemDao) {
         throw new Zend_Exception('Error: item parameter is not an item dao');
     }
     $userAgent = array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : '';
     $ip = $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     }
     /** @var Statistics_IpLocationModel $ipLocationModel */
     $ipLocationModel = MidasLoader::loadModel('IpLocation', 'statistics');
     $ipLocation = $ipLocationModel->getByIp($ip);
     if ($ipLocation == false) {
         /** @var Statistics_IpLocationDao $ipLocation */
         $ipLocation = MidasLoader::newDao('IpLocationDao', 'statistics');
         $ipLocation->setIp($ip);
         // we will perform the geolocation later, since it can be slow
         $ipLocation->setLatitude('');
         $ipLocation->setLongitude('');
         $ipLocationModel->save($ipLocation);
     }
     /** @var Statistics_DownloadDao $download */
     $download = MidasLoader::newDao('DownloadDao', 'statistics');
     $download->setItemId($item->getKey());
     $download->setIpLocationId($ipLocation->getKey());
     $download->setDate(date('Y-m-d H:i:s'));
     $download->setUserAgent($userAgent);
     if ($user instanceof UserDao) {
         $download->setUserId($user->getKey());
     }
     $this->save($download);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:34,代码来源:DownloadBase.php


示例19: schedulePerformCleanupJob

 /**
  * Schedule the perform cleanup job.
  *
  * @param int $days days to keep partial files
  * @param string $tempDirectory temporary directory
  * @param null|UserDao $userDao user scheduling the job
  */
 public function schedulePerformCleanupJob($days, $tempDirectory, $userDao = null)
 {
     /**  @var Scheduler_JobModel $jobModel */
     $jobModel = MidasLoader::loadModel('Job', 'scheduler');
     $jobDaos = $jobModel->getJobsByTask('TASK_CLEANUP_PERFORM_CLEANUP');
     $cleanupJobDao = false;
     foreach ($jobDaos as $jobDao) {
         if ($jobDao->getTask() === 'TASK_CLEANUP_PERFORM_CLEANUP') {
             $cleanupJobDao = $jobDao;
             break;
         }
     }
     if ($cleanupJobDao === false) {
         /** @var Scheduler_JobDao $cleanupJobDao */
         $cleanupJobDao = MidasLoader::newDao('JobDao', 'scheduler');
         $cleanupJobDao->setTask('TASK_CLEANUP_PERFORM_CLEANUP');
         $cleanupJobDao->setPriority(1);
         $cleanupJobDao->setRunOnlyOnce(0);
         $cleanupJobDao->setFireTime(date('Y-m-d', strtotime('+1 day' . date('Y-m-d H:i:s'))) . ' 01:00:00');
         $cleanupJobDao->setTimeInterval(86400);
         $cleanupJobDao->setStatus(SCHEDULER_JOB_STATUS_TORUN);
         if (!is_null($userDao)) {
             $cleanupJobDao->setCreatorId($userDao->getKey());
         }
     }
     $cleanupJobDao->setParams(JsonComponent::encode(array('days' => $days, 'tempDirectory' => $tempDirectory)));
     $jobModel->save($cleanupJobDao);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:35,代码来源:AdminComponent.php


示例20: postUpgrade

 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_PHMAGICK, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_JPG, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, $config->get('imagemagick', MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, $config->get('useThumbnailer', MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, $config->get('thumbnailer', MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->imageFormats);
         unset($config->global->imagemagick);
         unset($config->global->thumbnailer);
         unset($config->global->useThumbnailer);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:30,代码来源:1.1.0.php



注:本文中的MidasLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Migration类代码示例发布时间:2022-05-23
下一篇:
PHP Method类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap