本文整理汇总了PHP中HSetting类的典型用法代码示例。如果您正苦于以下问题:PHP HSetting类的具体用法?PHP HSetting怎么用?PHP HSetting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HSetting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Executes the widgets
*/
public function run()
{
if (Yii::app()->user->isGuest) {
return;
}
// Active tour flag not set
if (!isset($_GET['tour'])) {
return;
}
// Tour only possible when we are in a module
if (Yii::app()->controller->module === null) {
return;
}
// Check if tour is activated by admin and users
if (HSetting::Get('enable', 'tour') == 0 || Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour") == 1) {
return;
}
$this->loadResources();
// save current module and controller id's
$currentModuleId = Yii::app()->controller->module->id;
$currentControllerId = Yii::app()->controller->id;
if ($currentModuleId == "dashboard" && $currentControllerId == "dashboard") {
$this->render('guide_interface');
} elseif ($currentModuleId == "space" && $currentControllerId == "space") {
$this->render('guide_spaces', array());
} elseif ($currentModuleId == "user" && $currentControllerId == "profile") {
$this->render('guide_profile', array());
} elseif ($currentModuleId == "admin" && $currentControllerId == "module") {
$this->render('guide_administration', array());
}
}
示例2: attachFiles
/**
* Attaches files by url which found in content text.
* This is experimental and only supports image files at the moment.
*
* @param HActiveRecord $record to bind files to
* @param String $text to parse for links
*/
public static function attachFiles($record, $text)
{
if (!$record instanceof HActiveRecord) {
throw new CException("Invalid content object given!");
}
$max = 5;
$count = 1;
$text = preg_replace_callback('/http(.*?)(\\s|$)/i', function ($match) use(&$count, &$max, &$record) {
if ($max > $count) {
$url = $match[0];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
if (HSetting::Get('enabled', 'proxy')) {
curl_setopt($ch, CURLOPT_PROXY, HSetting::Get('server', 'proxy'));
curl_setopt($ch, CURLOPT_PROXYPORT, HSetting::Get('port', 'proxy'));
if (defined('CURLOPT_PROXYUSERNAME')) {
curl_setopt($ch, CURLOPT_PROXYUSERNAME, HSetting::Get('user', 'proxy'));
}
if (defined('CURLOPT_PROXYPASSWORD')) {
curl_setopt($ch, CURLOPT_PROXYPASSWORD, HSetting::Get('pass', 'proxy'));
}
if (defined('CURLOPT_NOPROXY')) {
curl_setopt($ch, CURLOPT_NOPROXY, HSetting::Get('noproxy', 'proxy'));
}
}
$ret = curl_exec($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
list($headers, $outputContent) = explode("\r\n\r\n", $ret, 2);
curl_close($ch);
if ($httpCode == 200 && substr($contentType, 0, 6) == 'image/') {
$extension = 'img';
if ($contentType == 'image/jpeg' || $contentType == 'image/jpg') {
$extension = 'jpg';
} elseif ($contentType == 'image/gif') {
$extension = 'gif';
} elseif ($contentType == 'image/png') {
$extension = 'png';
}
$file = new File();
$file->object_model = get_class($record);
$file->object_id = $record->getPrimaryKey();
$file->mime_type = $contentType;
$file->title = "Link Image";
$file->file_name = "LinkImage." . $extension;
$file->newFileContent = $outputContent;
$file->validate();
$file->save();
}
}
$count++;
}, $text);
}
示例3: up
public function up()
{
if (HSetting::isInstalled()) {
$this->alterColumn('profile', 'zip', 'VARCHAR(10) DEFAULT NULL');
$this->update('profile_field', array('field_type_class' => 'ProfileFieldTypeText', 'field_type_config' => '{"minLength":null,"maxLength":10,"validator":null,"default":null,"regexp":null,"regexpErrorMessage":null}'), 'internal_name="zip"');
}
}
示例4: actionIndex
/**
* Configuration Action for Super Admins
*/
public function actionIndex()
{
Yii::import('library.forms.*');
$form = new LibraryAdminForm();
// uncomment the following code to enable ajax-based validation
//if (isset($_POST['ajax']) && $_POST['ajax'] === 'LibraryAdminForm') {
// echo CActiveForm::validate($form);
// Yii::app()->end();
//}
if (isset($_POST['LibraryAdminForm'])) {
$_POST['LibraryAdminForm'] = Yii::app()->input->stripClean($_POST['LibraryAdminForm']);
$form->attributes = $_POST['LibraryAdminForm'];
if ($form->validate()) {
$form->globalPublicLibrary = HSetting::Set('globalPublicLibrary', $form->globalPublicLibrary, 'library');
$form->disclaimerWidget = HSetting::Set('disclaimerWidget', $form->disclaimerWidget, 'library');
$form->disclaimerTitle = HSetting::Set('disclaimerTitle', $form->disclaimerTitle, 'library');
$form->disclaimerContent = HSetting::Set('disclaimerContent', $form->disclaimerContent, 'library');
$this->redirect(Yii::app()->createUrl('library/admin/index'));
}
} else {
$form->globalPublicLibrary = HSetting::Get('globalPublicLibrary', 'library');
$form->disclaimerWidget = HSetting::Get('disclaimerWidget', 'library');
$form->disclaimerTitle = HSetting::Get('disclaimerTitle', 'library');
$form->disclaimerContent = HSetting::Get('disclaimerContent', 'library');
}
$this->render('index', array('model' => $form));
}
示例5: actionIndex
/**
* This is the action to handle external exceptions.
*/
public function actionIndex()
{
if ($error = Yii::app()->errorHandler->error) {
if (Yii::app()->request->isAjaxRequest) {
echo CHtml::encode($error['message']);
return;
}
/**
* Switch to plain base layout, in case the user is not logged in
* and public access is disabled.
*/
if (Yii::app()->user->isGuest && !HSetting::Get('allowGuestAccess', 'authentication_internal')) {
$this->layout = "application.views.error._layout";
}
if ($error['type'] == 'CHttpException') {
switch ($error['code']) {
case 401:
Yii::app()->user->returnUrl = Yii::app()->request->requestUri;
return $this->render('401', $error);
break;
}
}
$this->render('index', $error);
}
}
示例6: up
public function up()
{
$connection = $this->getDbConnection();
$command = $connection->commandBuilder->createFindCommand('user', new CDbCriteria());
$reader = $command->query();
foreach ($reader as $row) {
// Ignore deleted users
if ($row['status'] == 3) {
continue;
}
$userId = $row['id'];
$receive_email_notifications = $row['receive_email_notifications'];
$receive_email_messaging = $row['receive_email_messaging'];
$receive_email_activities = $row['receive_email_activities'];
$insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_notifications', 'value' => $receive_email_notifications));
$insertCommand->execute();
$insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_messaging', 'value' => $receive_email_messaging));
$insertCommand->execute();
$insertCommand = $connection->commandBuilder->createInsertCommand('user_setting', array('user_id' => $userId, 'module_id' => 'core', 'name' => 'receive_email_activities', 'value' => $receive_email_activities));
$insertCommand->execute();
}
$this->dropColumn('user', 'receive_email_notifications');
$this->dropColumn('user', 'receive_email_messaging');
$this->dropColumn('user', 'receive_email_activities');
if (HSetting::isInstalled()) {
$this->insert('setting', array('name' => 'receive_email_activities', 'value' => '1', 'name' => 'mailing'));
$this->insert('setting', array('name' => 'receive_email_notifications', 'value' => '2', 'name' => 'mailing'));
}
}
示例7: run
/**
* Executes the widget.
*/
public function run()
{
$blacklisted_objects = explode(',', HSetting::GetText('showFilesWidgetBlacklist', 'file'));
if (!in_array(get_class($this->object), $blacklisted_objects)) {
$files = File::getFilesOfObject($this->object);
$this->render('showFiles', array('files' => $files, 'maxPreviewImageWidth' => HSetting::Get('maxPreviewImageWidth', 'file'), 'maxPreviewImageHeight' => HSetting::Get('maxPreviewImageHeight', 'file'), 'hideImageFileInfo' => HSetting::Get('hideImageFileInfo', 'file')));
}
}
示例8: actionIndex
/**
* Dashboard Index
*
* Show recent wall entries for this user
*/
public function actionIndex()
{
if (Yii::app()->user->isGuest) {
$this->render('index_guest', array());
} else {
$this->render('index', array('showProfilePostForm' => HSetting::Get('showProfilePostForm', 'dashboard')));
}
}
示例9: up
public function up()
{
if (HSetting::isInstalled()) {
$this->insert('setting', array('name' => 'enable_html5_desktop_notifications', 'value' => 0, 'module_id' => 'notification'));
}
$this->addColumn('notification', 'desktop_notified', 'tinyint(1) DEFAULT 0');
$this->update('notification', array('desktop_notified' => 1));
}
示例10: doBaseTasks
/**
* Do general tasks used application whide
*/
protected function doBaseTasks()
{
$this->showTestHeadline("Checking application base structure");
if (HSetting::Get('secret') == "" || HSetting::Get('secret') == null) {
HSetting::Set('secret', UUID::v4());
$this->showFix('Setting missing application secret!');
}
}
示例11: setupRequestInfo
/**
* Sets some mandatory request infos to ensure absolute url creation.
* These values are extracted from baseUrl which is stored as HSetting.
*/
private function setupRequestInfo()
{
$parsedUrl = parse_url(HSetting::Get('baseUrl'));
$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
$port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';
Yii::app()->request->setHostInfo($parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $port);
Yii::app()->request->setBaseUrl(HSetting::Get('baseUrl'));
Yii::app()->request->setScriptUrl($path . '/index.php');
}
示例12: onDashboardSidebarInit
public static function onDashboardSidebarInit($event)
{
if (Yii::app()->user->isGuest) {
return;
}
if (HSetting::Get('enable', 'tour') == 1 && Yii::app()->user->getModel()->getSetting("hideTourPanel", "tour") != 1) {
$event->sender->addWidget('application.modules_core.tour.widgets.TourDashboardWidget', array(), array('sortOrder' => 0));
}
}
示例13: run
public function run()
{
$disclaimerWidget = HSetting::Get('disclaimerWidget', 'library');
$disclaimerTitle = HSetting::Get('disclaimerTitle', 'library');
$disclaimerContent = HSetting::Get('disclaimerContent', 'library');
if ($disclaimerWidget) {
$this->render('disclaimerPanel', array('disclaimerTitle' => $disclaimerTitle, 'disclaimerContent' => $disclaimerContent));
}
}
示例14: send
public function send($email)
{
$message = new HMailMessage();
$message->addFrom(HSetting::Get('systemEmailAddress', 'mailing'), HSetting::Get('systemEmailName', 'mailing'));
$message->addTo($email);
$message->view = "application.views.mail.TextOnly";
$message->subject = $this->subject;
$message->setBody(array('message' => $this->message), 'text/html');
Yii::app()->mail->send($message);
}
示例15: actionIndex
public function actionIndex()
{
$criteria = new CDbCriteria();
if (HSetting::Get('roomOrder', 'room') == 0) {
$criteria->order = 'name ASC';
} else {
$criteria->order = 'last_visit DESC';
}
$memberships = RoomMembership::model()->with('room')->findAllByAttributes(array('user_id' => Yii::app()->user->id, 'status' => RoomMembership::STATUS_MEMBER), $criteria);
$this->renderPartial('index', array('memberships' => $memberships), false, true);
}