本文整理汇总了PHP中Settings::getProtected方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getProtected方法的具体用法?PHP Settings::getProtected怎么用?PHP Settings::getProtected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::getProtected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load($name, $options = array())
{
$db = Settings::getProtected('db');
$auth = Settings::getProtected('auth');
$auth->forceAuthentication();
$username = $auth->getUsername();
if (array_key_exists('include-removed', $options) && $options['include-removed'] == true) {
$includeRemoved = true;
} else {
$includeRemoved = false;
}
$items = array();
$results = $db->loadQueue($name, $includeRemoved);
if (strpos($name, 'proof') != false) {
$type = 'proof';
} else {
if (strpos($name, 'review') != false) {
$type = 'review';
}
}
foreach ($results as $result) {
$itemID = $result['item_id'];
$projectID = $result['project_id'];
$item = new Item($db);
$item->loadWithProjectID($itemID, $projectID, $username, $type);
array_push($items, $item);
}
return $items;
}
示例2: Item
public function Item($itemId = '', $projectSlug = '', $username = '', $type = 'proof')
{
$this->db = Settings::getProtected('db');
if ($itemId && $projectSlug) {
$this->load($itemId, $projectSlug, $username, $type);
}
}
示例3: sendMessage
public static function sendMessage($to, $subject, $message)
{
$admin_email = Settings::getProtected('admin_email');
$headers = "From: {$admin_email}" . "\r\n";
$headers .= "Reply-To: {$admin_email}" . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
return mail($to, $subject, $message, $headers);
}
示例4: forceClearance
public static function forceClearance($roles, $user, $params = array(), $error = 'error.insufficient_rights')
{
$app_url = Settings::getProtected('app_url');
$i18n = new I18n("../translations", Settings::getProtected('language'));
if (!self::verify($roles, $user, $params)) {
Utils::redirectToDashboard('', $i18n->t($error));
return false;
}
return true;
}
示例5: ItemTypeUploader
public function ItemTypeUploader($projectSlug)
{
$this->itemData = array();
$this->items = array();
$this->files = array();
$this->projectSlug = $projectSlug;
$sysPath = Settings::getProtected('sys_path');
$this->tempDir = "{$sysPath}/htdocs/media/temp/{$this->projectSlug}";
$project = new Project($projectSlug);
$this->projectId = $project->project_id;
}
示例6: redirectToDashboard
public static function redirectToDashboard($message, $error)
{
$app_url = Settings::getProtected('app_url');
if ($message != '') {
$_SESSION['ub_message'] = trim($message);
}
if ($error != '') {
$_SESSION['ub_error'] = trim($error);
}
header("Location: {$app_url}");
}
示例7: load
public static function load($params)
{
$item = $params['item'];
$type = $params['type'];
$auth = Settings::getProtected('auth');
$auth->forceAuthentication();
$username = $auth->getUsername();
$user = new User($username);
// Make sure user has access (member of project, item is in queue)
// TODO: Finish
return $user->loadTranscript($item, $type);
}
示例8: admin
public static function admin($params)
{
$format = Utils::getFormat($params['args'], 0, 2);
$app_url = Settings::getProtected('app_url');
$db = Settings::getProtected('db');
$user = User::getAuthenticatedUser();
// Make sure the user is at least creator or admin
RoleController::forceClearance(array('system.creator', 'system.admin'), $user);
// Get latest work for the user's projects
$latestWorkList = $db->getAdminProjectsLatestWork($user->username, 5);
$latestWork = array();
foreach ($latestWorkList as $work) {
$qn = $work['queue_name'];
$type = substr($qn, strpos($qn, '.') + 1, strpos($qn, ':') - strpos($qn, '.') - 1);
$username = substr($qn, strpos($qn, ':') + 1);
$item = new Item($work['item_id'], $work['project_slug']);
$project = new Project($work['project_slug']);
if ($item->project_type == 'system') {
$transcriptURL = "{$app_url}/projects/" . $item->project_slug . "/items/" . $item->item_id . "/{$type}/{$username}";
$editURL = "{$app_url}/projects/" . $item->project_slug . "/items/" . $item->item_id . "/edit";
} else {
$transcriptURL = "{$app_url}/" . $item->project_owner . "/projects/" . $item->project_slug . "/items/" . $item->item_id . "/{$type}/{$username}";
$editURL = "{$app_url}/" . $item->project_owner . "/projects/" . $item->project_slug . "/items/" . $item->item_id . "/edit";
}
array_push($latestWork, array('item' => $item->getResponse(), 'project' => $project->getResponse(), 'type' => $type, 'username' => $username, 'date_completed' => $work['date_completed'], 'transcript_url' => $transcriptURL, 'edit_url' => $editURL));
}
$newestMembers = $db->getNewestProjectMembers($user->username, 5);
// Only get list of users if they're a site admin
$users = array();
if ($user->role == 'admin') {
$usernameList = $db->getUsers();
foreach ($usernameList as $username) {
$tempUser = new User($username['username']);
$tempUserArray = $tempUser->getResponse();
// Get list of projects they're working on
$projects = $db->getUserProjectsWithStats($username['username']);
$tempUserArray['projects'] = $projects;
array_push($users, $tempUserArray);
}
}
$response = array('page_title' => 'Admin Dashboard', 'user' => $user->getResponse(), 'latest_work' => $latestWork, 'newest_members' => $newestMembers, 'users' => $users);
switch ($format) {
case 'json':
echo json_encode($response);
break;
case 'html':
Template::render('admin_dashboard', $response);
break;
}
}
示例9: render
public static function render($page, $options, $theme = 'core')
{
$cached = Settings::getProtected('theme_cached');
// If there's a system-wide theme in config.yaml, use it as the default instead
$settingsTheme = Settings::getProtected('theme');
if ($settingsTheme != 'core' && $theme == 'core') {
$theme = $settingsTheme;
}
if ($cached) {
$twig_opts = array('cache' => '../templates/cache');
} else {
$twig_opts = array();
}
$loader = new Twig_Loader_Filesystem(array("../templates/{$theme}", "../templates/core"));
$twig = new Twig_Environment($loader, $twig_opts);
$options['title'] = Settings::getProtected('title');
$options['app_url'] = Settings::getProtected('app_url');
$options['google_analytics'] = Settings::getProtected('google_analytics');
$options['theme_root'] = $options['app_url'] . "/themes/{$theme}";
$options['i18n'] = new I18n("../translations", Settings::getProtected('language'));
$options['message'] = Utils::SESSION('ub_message');
$options['error'] = Utils::SESSION('ub_error');
$auth = Settings::getProtected('auth');
if ($auth->authenticated()) {
$username = $auth->getUsername();
if (isset($username)) {
$options['username'] = $auth->getUsername();
}
}
// Prepare the methods they want
if (array_key_exists('registered_methods', $options)) {
// TODO: get user token
$userToken = 'foo';
$appName = 'unbindery';
$privateKey = Settings::getProtected('private_key');
$devKeys = Settings::getProtected('devkeys');
$devKey = $devKeys['unbindery'];
$options['methods'] = array();
foreach ($options['registered_methods'] as $method) {
// Create the signature hash for each method we'll use on the page in Javascript
$options['methods'][$method] = array("name" => $method, "value" => md5($method . $userToken . $appName . $privateKey . $devKey));
}
}
echo $twig->render("{$page}.html", $options);
// Now that we've displayed it, get rid of it
unset($_SESSION['ub_message']);
unset($_SESSION['ub_error']);
}
示例10: preprocess
public function preprocess($filenames)
{
// Get settings
$sysPath = Settings::getProtected('sys_path');
$uploaders = Settings::getProtected('uploaders');
$chunkSize = $uploaders['Audio']['chunksize'];
$chunkOverlap = $uploaders['Audio']['chunkoverlap'];
$ffmpegPath = $uploaders['Audio']['ffmpeg'];
// Chunk each MP3 into smaller segments
foreach ($filenames as $file) {
$path = "{$this->tempDir}/{$file}";
// These four lines from http://stackoverflow.com/questions/3069574/get-the-length-of-an-audio-file-php
$execStr = $ffmpegPath . " -i {$path} 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//";
$time = exec($execStr);
list($hms, $milli) = explode('.', $time);
list($hours, $minutes, $seconds) = explode(':', $hms);
$totalSeconds = $hours * 3600 + $minutes * 60 + $seconds;
$count = 1;
// If the MP3 is longer than the chunk size, split it
if ($totalSeconds > $chunkSize) {
$start = 0;
// Get the filename and extension
$filename = pathinfo($file, PATHINFO_FILENAME);
$ext = pathinfo($file, PATHINFO_EXTENSION);
// Get the size of the chunks, including the overlap
$chunkSeconds = $chunkSize + $chunkOverlap;
for ($start = 0; $start < $totalSeconds; $start += $chunkSize) {
// Prep output filename
$outputFilename = sprintf("{$filename}-%03d.{$ext}", $count);
$outputPath = "{$this->tempDir}/{$outputFilename}";
// And chunk the file
$execStr = $ffmpegPath . " -ss {$start} -i {$path} -t {$chunkSeconds} -acodec copy {$outputPath}";
exec($execStr);
// Add to files array
array_push($this->files, $outputFilename);
$count++;
}
}
}
// And create the item info array
foreach ($this->files as $file) {
// Strip off the extension for the title
$title = pathinfo($file, PATHINFO_FILENAME);
$item = array("title" => $title, "project_id" => $this->projectId, "transcript" => "", "type" => "audio", "href" => $file);
array_push($this->itemData, $item);
}
}
示例11: parse
public static function parse($item, $action)
{
$auth = Settings::getProtected('auth');
$auth->forceAuthentication();
$username = $auth->getUsername();
$user = new User($username);
// Parse the action
switch (trim($action)) {
case '@proofer':
$destinationQueue = "project.proof:" . $item->project_slug;
break;
case '@reviewer':
$destinationQueue = "project.review:" . $item->project_slug;
break;
default:
// username (defaults to proof, TODO: allow review as well)
$destinationQueue = "user.proof:" . $action;
break;
}
$queue = new Queue($destinationQueue);
$queue->add($item);
$queue->save();
}
示例12: createAccount
public function createAccount($user)
{
$app_url = Settings::getProtected('app_url');
$email_subject = Settings::getProtected('email_subject');
$admin_email = Settings::getProtected('admin_email');
$i18n = new I18n("../translations", Settings::getProtected('language'));
// Add username/email here if they're not already in Unbindery (unnecessary for Alibaba)
// Example:
// $user->username = $this->getUsername();
// $user->email = $this->getEmail();
// Generate hash
$user->hash = md5($user->email . $user->username . time());
// Add user to the database or update if they're already there
$user->save();
// Send confirmation link to user via email
$message = $i18n->t('signup.confirmation_email', array("url" => "{$app_url}/signup/activate/{$user->hash}"));
$status = Mail::sendMessage($user->email, "{$email_subject} " . $i18n->t('signup.confirmation_link'), $message);
if ($status == 1) {
$status = "done";
} else {
$status = "error mailing";
}
$status = Mail::sendMessage($admin_email, "{$email_subject} " . $i18n->t('signup.new_signup'), $i18n->t('signup.new_user') . " {$user->username} <{$user->email}>");
}
示例13: sendNotification
public static function sendNotification($to, $notification, $params)
{
$i18n = new I18n("../translations", Settings::getProtected('language'));
error_log("Sending {$notification}.subject / {$notification}.message");
$subject = self::replaceVariables($i18n->t("{$notification}.subject"), $params);
$email_subject = Settings::getProtected('email_subject');
if ($email_subject) {
$subject = "{$email_subject} {$subject}";
}
$message = self::replaceVariables($i18n->t("{$notification}.message"), $params);
Mail::sendMessage($to, $subject, $message);
}
示例14: getAuthenticatedUser
public static function getAuthenticatedUser()
{
$auth = Settings::getProtected('auth');
$auth->forceAuthentication();
return new User($auth->getUsername());
}
示例15: removeFileForItem
public static function removeFileForItem($item)
{
$sysPath = Settings::getProtected('sys_path');
// Load the project
$project = new Project($item->project_slug);
// Set up the target dir
if ($project->type == 'system') {
$projectDir = "{$sysPath}/htdocs/media/projects/{$project->slug}";
} else {
if ($project->type == 'user') {
$projectDir = "{$sysPath}/htdocs/media/users/{$project->owner}/{$project->slug}";
}
}
// File path
$filePath = "{$projectDir}/{$item->href}";
// Remove the file
if ($projectDir != '' && file_exists($filePath)) {
return unlink($filePath);
}
return false;
}