本文整理汇总了PHP中Dashboard::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Dashboard::save方法的具体用法?PHP Dashboard::save怎么用?PHP Dashboard::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dashboard
的用法示例。
在下文中一共展示了Dashboard::save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initForUser
public static function initForUser($id)
{
foreach (array('Salon', 'Cuisine', 'Chambre', 'Garage', 'Système') as $room) {
$entity = new Dashboard();
$entity->create();
$entity->user = $id;
$entity->label = $room;
$entity->default = 0;
$entity->save();
}
$entity = new Dashboard();
$entity->create();
$entity->user = $id;
$entity->label = "Général";
$entity->default = 1;
$entity->save();
$dashboard = $entity->id;
$entity = new Widget();
$entity->create();
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_profil\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_system\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_network\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_hdd\', \'null\', \'3\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_disk\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_gpio\', \'null\', \'1\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_services\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_users\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_vocal\', \'null\', \'1\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("model", "data", "cell", "column", "minified","dashboard") VALUES (\'dash_monitoring_logs\', \'null\', \'1\', \'2\', \'\',\'' . $dashboard . '\');');
return $dashboard;
}
示例2: createDashboardByNameForOwner
public static function createDashboardByNameForOwner($name, $owner)
{
$dashboard = new Dashboard();
$dashboard->name = $name;
$dashboard->layoutId = Dashboard::getNextLayoutId();
$dashboard->owner = $owner;
$dashboard->layoutType = '50,50';
// Not Coding Standard
$dashboard->isDefault = false;
$saved = $dashboard->save();
assert('$saved');
return $dashboard;
}
示例3: setDefaultDashboardForUser
/**
* Used to set the default dashboard information
* for dashboard layoutId=1 for each user
* @return Dashboard model.
*/
private static function setDefaultDashboardForUser($user)
{
assert('$user instanceof User && $user->id > 0');
$dashboard = new Dashboard();
$dashboard->name = Zurmo::t('HomeModule', 'Dashboard');
$dashboard->layoutId = Dashboard::DEFAULT_USER_LAYOUT_ID;
$dashboard->owner = $user;
$dashboard->layoutType = '50,50';
// Not Coding Standard
$dashboard->isDefault = true;
$saved = $dashboard->save();
assert('$saved');
// TODO - deal with the properly.
return $dashboard;
}
示例4: testCreateDashboardFromPost
/**
* testGetNextLayoutId
*/
public function testCreateDashboardFromPost()
{
$user = User::getByUserName('billy');
Yii::app()->user->userModel = $user;
$dashboard = new Dashboard();
$dashboard->owner = $user;
$dashboard->layoutId = Dashboard::getNextLayoutId();
$fakePost = array('name' => 'abc123', 'layoutType' => '50,50');
$dashboard->setAttributes($fakePost);
$dashboard->validate();
$this->assertEquals(array(), $dashboard->getErrors());
$this->assertTrue($dashboard->save());
}
示例5: actionCreate
/**
* Creates a new Dashboard model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Dashboard();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->CORP_ID]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: array
function &createUserDashboard($user_id)
{
$test = array();
$dashboard = new Dashboard();
$dashboard->assigned_user_id = $user_id;
$dashboard->created_by = $user_id;
$dashboard->modified_user_id = $user_id;
$dashboard->name = "Home";
$dashboard->content = $this->getDefaultDashboardContents();
$dashboard->save();
return $dashboard;
}
示例7: dashboard_plugin_actions
function dashboard_plugin_actions()
{
global $myUser, $_, $conf;
switch ($_['action']) {
case 'GET_WIDGETS':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Dashboard.class.php';
require_once dirname(__FILE__) . '/Widget.class.php';
$dashManager = new Dashboard();
$dashManager->change(array('default' => '0'));
$dashManager->change(array('default' => '1'), array('id' => $_['dashboard']));
$widgetManager = new Widget();
$model = array();
Plugin::callHook("widgets", array(&$model));
$widgets = $widgetManager->loadAll(array('dashboard' => $_['dashboard']), 'cell');
$data = array();
foreach ($widgets as $widget) {
$data[] = array('data' => $widget->data, 'column' => $widget->column, 'id' => $widget->id, 'cell' => $widget->cell, 'minified' => $widget->minified, 'model' => $widget->model);
}
echo json_encode(array('model' => $model, 'data' => $data));
break;
case 'ADD_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widget = new Widget();
$widget->data = json_encode($_POST['data']);
$widget->column = $_['column'];
$widget->cell = $_['cell'];
$widget->model = $_['model'];
$widget->dashboard = $_['view'];
$widget->save();
$response['id'] = $widget->id;
echo json_encode($response);
break;
case 'MINIMIZE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager = $widgetManager->getById($_['id']);
$widgetManager->minified = 1;
$widgetManager->save();
echo json_encode($response);
break;
case 'MAXIMIZE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager = $widgetManager->getById($_['id']);
$widgetManager->minified = 0;
$widgetManager->save();
echo json_encode($response);
break;
case 'MOVE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
foreach ($_['sort']['cells'] as $id => $sort) {
$widgetManager->change(array('cell' => $sort['cell'], 'column' => $sort['column']), array('id' => $id));
}
echo json_encode($response);
break;
case 'DELETE_WIDGET':
header('Content-type: application/json');
require_once dirname(__FILE__) . '/Widget.class.php';
$response = array();
$widgetManager = new Widget();
$widgetManager->delete(array('id' => $_['id']));
echo json_encode($response);
break;
case 'DASH_ADD_VIEW':
global $_, $myUser;
require_once dirname(__FILE__) . '/Dashboard.class.php';
$entity = new Dashboard();
$entity->user = $myUser->getId();
$entity->label = $_['viewName'];
$entity->default = 0;
$entity->save();
header('location: setting.php?section=preference&block=dashboard');
break;
case 'DASH_DELETE_VIEW':
global $_, $myUser;
require_once dirname(__FILE__) . '/Dashboard.class.php';
$entity = new Dashboard();
$entity->delete(array('id' => $_['id']));
header('location: setting.php?section=preference&block=dashboard');
break;
}
}
示例8: createDashboard
/**
* createDashboard
* --------------------------------------------------
* Creating a dashboard dedicated to braintree widgets.
* --------------------------------------------------
*/
private function createDashboard()
{
/* Creating dashboard. */
$dashboard = new Dashboard(array('name' => 'Braintree dashboard', 'background' => TRUE, 'number' => $this->user->dashboards->max('number') + 1));
$dashboard->user()->associate($this->user);
$dashboard->save();
/* Adding widgets */
$mrrWidget = new BraintreeMrrWidget(array('position' => '{"col":1,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arrWidget = new BraintreeArrWidget(array('position' => '{"col":5,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arpuWidget = new BraintreeArpuWidget(array('position' => '{"col":9,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
/* Associating dashboard */
$mrrWidget->dashboard()->associate($dashboard);
$arrWidget->dashboard()->associate($dashboard);
$arpuWidget->dashboard()->associate($dashboard);
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
/* Populating data */
$mrrWidget->collectData();
$arrWidget->collectData();
$arpuWidget->collectData();
}
示例9: Dashboard
<?php
global $myUser;
require_once 'Dashboard.class.php';
require_once 'Widget.class.php';
$entity = new Dashboard();
$entity->create();
$entity->user = $myUser->getId();
$entity->label = "Général";
$entity->default = 1;
$entity->save();
$dashboard = $entity->id;
$entity = new Widget();
$entity->create();
$s1 = new Section();
$s1->setLabel('dashboard');
$s1->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (1, \'dash_profil\', \'null\', \'0\', \'0\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (2, \'dash_monitoring_ram\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (3, \'dash_monitoring_system\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (4, \'dash_monitoring_network\', \'null\', \'0\', \'2\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (5, \'dash_monitoring_hdd\', \'null\', \'3\', \'1\', \'\',\'' . $dashboard . '\');');
$entity->customQuery('INSERT INTO "yana_plugin_dashboard" ("id", "model", "data", "cell", "column", "minified","dashboard") VALUES (6, \'dash_monitoring_disk\', \'null\', \'0\', \'1\', \'\',\'' . $dashboard . '\');');
示例10: actionCreateDashboard
public function actionCreateDashboard()
{
$dashboard = new Dashboard();
if (isset($_POST['Dashboard'])) {
$dashboard->owner = Yii::app()->user->userModel;
$dashboard->layoutId = Dashboard::getNextLayoutId();
$dashboard->setAttributes($_POST['Dashboard']);
assert('in_array($dashboard->layoutType, array_keys(Dashboard::getLayoutTypesData()))');
if ($dashboard->save()) {
GeneralCache::forgetAll();
//Ensure menu refreshes
$this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id));
}
}
$editView = new DashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard, Zurmo::t('HomeModule', 'Create Dashboard'));
$view = new HomePageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editView));
echo $view->render();
}
示例11: createDashboard
/**
* createDashboard
* --------------------------------------------------
* Creating a dashboard dedicated to stripe widgets.
* --------------------------------------------------
*/
private function createDashboard()
{
/* Creating dashboard. */
$dashboard = new Dashboard(array('name' => 'Stripe dashboard', 'background' => TRUE, 'number' => $this->user->dashboards->max('number') + 1));
$dashboard->user()->associate($this->user);
$dashboard->save();
/* Adding widgets */
$mrrWidget = new StripeMrrWidget(array('position' => '{"col":1,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arrWidget = new StripeArrWidget(array('position' => '{"col":5,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arpuWidget = new StripeArpuWidget(array('position' => '{"col":9,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
/* Associating dashboard */
$mrrWidget->dashboard()->associate($dashboard);
$arrWidget->dashboard()->associate($dashboard);
$arpuWidget->dashboard()->associate($dashboard);
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
/* Creating data for the last 30 days. */
$calculator = new StripeLastMonthCalculator($this->user);
$lastMonthData = $calculator->getLastMonthData();
$mrrWidget->data->raw_value = json_encode($lastMonthData['mrr']);
$arrWidget->data->raw_value = json_encode($lastMonthData['arr']);
$arpuWidget->data->raw_value = json_encode($lastMonthData['arpu']);
$mrrWidget->data->save();
$arrWidget->data->save();
$arpuWidget->data->save();
$mrrWidget->state = 'active';
$arrWidget->state = 'active';
$arpuWidget->state = 'active';
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
}
示例12: makePersonalAutoDashboard
/**
* makePersonalAutoDashboard
* creates a new Dashboard object and personal widgets
* from the POST data
* --------------------------------------------------
* @param (User) ($user) The current user
* @param (array) ($widgetdata) Personal widgets data
* @return (Dashboard) ($dashboard) The new Dashboard object
* --------------------------------------------------
*/
private function makePersonalAutoDashboard($user, $widgetdata)
{
/* Create new dashboard */
$dashboard = new Dashboard();
$dashboard->user_id = $user->id;
$dashboard->name = 'My personal dashboard';
$dashboard->background = 'On';
/* Save dashboard object */
$dashboard->save();
/* Create clock widget */
if (array_key_exists('widget-clock', $widgetdata)) {
$clockwidget = new ClockWidget();
$clockwidget->dashboard()->associate($dashboard);
$clockwidget->state = 'active';
$clockwidget->position = '{"row":1,"col":3,"size_x":8,"size_y":3}';
/* Save clock widget object */
$clockwidget->save();
}
/* Create greetings widget */
if (array_key_exists('widget-greetings', $widgetdata)) {
$greetingswidget = new GreetingsWidget();
$greetingswidget->dashboard()->associate($dashboard);
$greetingswidget->state = 'active';
$greetingswidget->position = '{"row":4,"col":3,"size_x":8,"size_y":1}';
/* Save greetings widget object */
$greetingswidget->save();
}
/* Create quote widget */
if (array_key_exists('widget-quote', $widgetdata)) {
$quotewidget = new QuoteWidget();
$quotewidget->dashboard()->associate($dashboard);
$quotewidget->state = 'active';
$quotewidget->position = '{"row":12,"col":1,"size_x":12,"size_y":1}';
/* Save quote widget object */
$quotewidget->save();
}
/* Return */
return $dashboard;
}