本文整理汇总了PHP中Asset::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset::save方法的具体用法?PHP Asset::save怎么用?PHP Asset::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
/**
* Update data of the asset
*
* @param mixed $data
* @return void
*/
function put($data)
{
$tmpFile = PIMCORE_WEBDAV_TEMP . "/" . md5($this->asset->getId() . microtime());
file_put_contents($tmpFile, $data);
$data = file_get_contents($tmpFile);
unlink($tmpFile);
$this->asset->setData($data);
$this->asset->save();
}
示例2: run
public function run()
{
// create default user asset
$asset = Asset::where('filename', '=', 'default.png')->first();
if ($asset == NULL) {
$asset = new Asset();
$asset->filename = 'default.png';
$asset->path = 'assets/content/users';
$asset->save();
}
$admin = Role::where('name', '=', 'Admin')->first();
// create default roles
if ($admin == NULL) {
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
}
$adminUser = User::where('username', '=', 'admin')->first();
if ($adminUser != NULL) {
echo "Admin User Already Exsit";
} else {
$adminUser = new User();
$adminUser->username = 'admin';
$adminUser->email = 'admin@admin.com';
$adminUser->password = 'admin';
$adminUser->password_confirmation = 'admin';
$adminUser->confirmation_code = md5(uniqid(mt_rand(), true));
if ($adminUser->save()) {
$adminUser->attachRole($admin);
echo "Admin User Created";
}
}
}
示例3: setupDatabases
public function setupDatabases()
{
$name = $this->call('migrate', array('--path' => 'app/database/migrations/setup/'));
$name = $this->call('migrate');
// create the roles
$roles = ['Admin', 'Writer', 'Reader'];
foreach ($roles as $r) {
$role = Role::whereName($r)->first();
if ($role == null) {
$role = new Role();
$role->name = $r;
$role->display_name = $r;
$role->save();
$this->info("{$role->id} Creating Role:{$r}");
}
}
foreach (User::all() as $u) {
$this->info("{$u->id} : user: {$u->username}");
}
// add core assets
$m = Asset::findFromTag('missing-user-image');
if ($m == NULL) {
$m = new Asset();
$m->path = "assets/content/uploads";
$m->saveLocalFile(public_path('assets/content/common/missing/profile-default.png'), 'profile-default.png');
$m->tag = 'missing-user-image';
$m->shared = 1;
$m->type = Asset::ASSET_TYPE_IMAGE;
$m->save();
}
$this->comment("****\tAll Databases for Halp have been setup :-) \t****");
return;
}
示例4: save
function save()
{
$this->filter_access('Assets', 'roled_add', 'assets/index');
$asset = new Asset();
$asset->asset_name = $this->input->post('asset_name');
$asset->asset_status = $this->input->post('asset_status');
$asset->staff_id = $this->input->post('staff_id');
$asset->date = $this->input->post('date');
if ($asset->save()) {
$this->session->set_flashdata('message', 'Asset successfully created!');
redirect('assets/');
} else {
// Failed
$asset->error_message('custom', 'Field required');
$msg = $asset->error->custom;
$this->session->set_flashdata('message', $msg);
redirect('assets/add');
}
}
示例5: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$filename = $this->argument('filename');
if (!$this->option('testrun') == 'true') {
$this->comment('======= Importing ' . $filename . ' =========');
} else {
$this->comment('====== TEST ONLY Import for ' . $filename . ' ====');
$this->comment('============== NO DATA WILL BE WRITTEN ==============');
}
if (!ini_get("auto_detect_line_endings")) {
ini_set("auto_detect_line_endings", '1');
}
$csv = Reader::createFromPath($this->argument('filename'));
$csv->setNewline("\r\n");
$csv->setOffset(1);
$duplicates = '';
// Loop through the records
$nbInsert = $csv->each(function ($row) use($duplicates) {
$status_id = 1;
if (is_numeric($row[0])) {
$this->comment('User ' . $row[0] . ' is not a name - assume this user already exists');
} elseif ($row[0] == '') {
$this->comment('No user data provided - skipping user creation, just adding asset');
} else {
// Generate an email based on their name
$name = explode(" ", $row[0]);
$first_name = $name[0];
$last_name = '';
$email_last_name = '';
if ($first_name == 'Unknown') {
$status_id = 7;
}
if (!array_key_exists(1, $name)) {
$last_name = '';
$email_last_name = $last_name;
$email_prefix = $first_name;
} else {
// Loop through the rest of the explode so you don't truncate
for ($x = 0; $x < count($name); $x++) {
if ($x > 0 && $name[$x] != '') {
$last_name .= ' ' . $name[$x];
$email_last_name .= $name[$x];
}
}
$email_prefix = $first_name[0] . $email_last_name;
}
$email = strtolower(str_replace('.', '', $email_prefix)) . '@' . $this->option('domain');
$email = str_replace("'", '', $email);
$this->comment('Full Name: ' . $row[0]);
$this->comment('First Name: ' . $first_name);
$this->comment('Last Name: ' . $last_name);
$this->comment('Email: ' . $email);
$this->comment('Category Name: ' . $row[1]);
$this->comment('Item: ' . $row[2]);
$this->comment('Manufacturer ID: ' . $row[3]);
$this->comment('Model No: ' . $row[4]);
$this->comment('Serial No: ' . $row[5]);
$this->comment('Asset Tag: ' . $row[6]);
$this->comment('Location: ' . $row[7]);
}
$this->comment('------------- Action Summary ----------------');
if (isset($email)) {
if ($user = User::where('email', $email)->first()) {
$this->comment('User ' . $email . ' already exists');
} else {
// Create the user
$user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
// Find the group using the group id
$userGroup = Sentry::findGroupById(3);
// Assign the group to the user
$user->addGroup($userGroup);
$this->comment('User ' . $first_name . ' created');
}
} else {
$user = new User();
}
// Check for the location match and create it if it doesn't exist
if ($location = Location::where('name', $row[7])->first()) {
$this->comment('Location ' . $row[7] . ' already exists');
} else {
$location = new Location();
$location->name = e($row[7]);
$location->address = '';
$location->city = '';
$location->state = '';
$location->country = '';
$location->user_id = 1;
if (!$this->option('testrun') == 'true') {
if ($location->save()) {
$this->comment('Location ' . $row[7] . ' was created');
} else {
$this->comment('Something went wrong! Location ' . $row[1] . ' was NOT created');
}
} else {
$this->comment('Location ' . $row[7] . ' was (not) created - test run only');
//.........这里部分代码省略.........
示例6: setName
/**
* @return void
*/
function setName($name)
{
$this->asset->setFilename(Pimcore_File::getValidFilename($name));
$this->asset->save();
}
示例7: approve
public function approve()
{
//check the users group
$authorizers = Sentry::findGroupByName('Authorizers');
$admins = Sentry::findGroupByName('Admin');
//DLN authorizers
if (Sentry::getUser()->inGroup($authorizers)) {
$this->request_code = 1;
$this->save();
return array('success' => 1, 'message' => 'Request Approved', 'type' => $this->type);
} elseif (Sentry::getUser()->inGroup($admins)) {
//get all license types for request
$lcnsNames = $this->licenseTypes()->lists('name');
//get available license seats for each license type
$that = $this;
$toAdd = [];
if ($this->type == 'license') {
//TODO:: remove and place in seperate method - this will need to be used to update a request
foreach ($lcnsNames as $lcnsName) {
$lcnsSeat = DB::table('licenses')->join('license_types', 'licenses.type_id', '=', 'license_types.id')->join('license_seats', 'licenses.id', '=', 'license_seats.license_id')->orwhere(function ($query) use($lcnsName, $that) {
$query->where('license_types.name', '=', $lcnsName)->where('licenses.role_id', $that->role_id)->whereNull('license_seats.assigned_to');
})->first();
//if seats available add it to array for later processing, else return with error message
if ($lcnsSeat) {
$toAdd[$lcnsName] = $lcnsSeat;
} else {
$messageKey = str_replace(' ', '', strtolower($lcnsName));
$error = Lang::get('request.message_no_lcns.' . $lcnsName);
return array('success' => 0, 'message' => $error);
}
}
foreach ($toAdd as $key => $lcnsSeat) {
if ($key == 'SABA Publisher') {
//create computer name as an asset if it doesnt exist
if ($obj = DB::table('assets')->where('serial', $this->pc_name)->first(array('id'))) {
$asset = Asset::find($obj->id);
} else {
$asset = new Asset();
$asset->name = "DWAN PC";
$asset->serial = $this->pc_name;
$asset->asset_tag = $this->pc_name;
$asset->model_id = 7;
//TODO: Remove this hard coding for model id
$asset->status_id = 1;
$asset->assigned_to = $this->account->id;
}
$asset->role_id = $this->role_id;
$asset->save();
License::checkOutToAsset($lcnsSeat->id, $asset->id);
}
//checkout to account the request has been made for
License::checkOutToAccount($lcnsSeat->id, $this->account_id);
}
} elseif ($this->type == 'checkin') {
//clear license fields
$seat = LicenseSeat::find($this->license_id);
$seat->checkIn();
}
//detach requested licenses
$this->licenseTypes()->detach();
$type = $this->type;
//marked as closed
$this->delete();
return array('success' => 1, 'message' => 'Request Approved', 'type' => $type);
}
}
示例8: saveGoogleProfileImage
public static function saveGoogleProfileImage(&$google_user, &$user)
{
// profile image
//if(property_exists($google_user, 'picture')) {
$image_url = $google_user->picture;
if ($image_url) {
$image_url_parts = explode('?', $image_url);
$image_url = $image_url_parts[0];
$id = $user->id;
$image_name = $user->username . '_' . $id . '.jpg';
if ($user->profileImage && $user->profileImage->isShared() != true) {
$user->profileImage->removeOldFile();
$user->profileImage->saveRemoteAsset($image_url, $image_name, ASSET::ASSET_TYPE_IMAGE);
$user->profileImage->user()->associate($user);
} else {
$userImage = new Asset();
$userImage->path = 'assets/content/users';
$userImage->saveRemoteAsset($image_url, $image_name, ASSET::ASSET_TYPE_IMAGE);
$userImage->save();
$user->profileImage()->save($userImage);
$user->profileImage->user()->associate($user);
}
}
//}
}
示例9: makeDefaultProfileImage
public function makeDefaultProfileImage()
{
$userImage = $this->profileImage()->first();
if ($userImage == null) {
$userImage = new Asset();
}
$userImage->path = 'assets/content/users';
$userImage->saveRemoteImage('assets/content/common/porfile-default.png', $this->username . '_' . $this->id . '.png');
$userImage->user()->associate($this);
$userImage->save();
$this->profileImage()->save($userImage);
}
示例10: fire
//.........这里部分代码省略.........
$this->comment('Serial No: ' . $user_asset_serial);
$this->comment('Asset Tag: ' . $user_asset_tag);
$this->comment('Location: ' . $user_asset_location);
$this->comment('Purchase Date: ' . $user_asset_purchase_date);
$this->comment('Notes: ' . $user_asset_notes);
$this->comment('------------- Action Summary ----------------');
if ($user_email != '') {
if ($user = User::where('email', $user_email)->first()) {
$this->comment('User ' . $user_email . ' already exists');
} else {
// Create the user
$user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
// Find the group using the group id
$userGroup = Sentry::findGroupById(3);
// Assign the group to the user
$user->addGroup($userGroup);
$this->comment('User ' . $first_name . ' created');
}
} else {
$user = new User();
}
// Check for the location match and create it if it doesn't exist
if ($location = Location::where('name', $user_asset_location)->first()) {
$this->comment('Location ' . $user_asset_location . ' already exists');
} else {
$location = new Location();
$location->name = e($user_asset_location);
$location->address = '';
$location->city = '';
$location->state = '';
$location->country = '';
$location->user_id = 1;
if (!$this->option('testrun') == 'true') {
if ($location->save()) {
$this->comment('Location ' . $user_asset_location . ' was created');
} else {
$this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
}
} else {
$this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
}
}
// Check for the category match and create it if it doesn't exist
if ($category = Category::where('name', $user_asset_category)->where('category_type', 'asset')->first()) {
$this->comment('Category ' . $user_asset_category . ' already exists');
} else {
$category = new Category();
$category->name = e($user_asset_category);
$category->category_type = 'asset';
$category->user_id = 1;
if ($category->save()) {
$this->comment('Category ' . $user_asset_category . ' was created');
} else {
$this->comment('Something went wrong! Category ' . $user_asset_category . ' was NOT created');
}
}
// Check for the manufacturer match and create it if it doesn't exist
if ($manufacturer = Manufacturer::where('name', $user_asset_mfgr)->first()) {
$this->comment('Manufacturer ' . $user_asset_mfgr . ' already exists');
} else {
$manufacturer = new Manufacturer();
$manufacturer->name = e($user_asset_mfgr);
$manufacturer->user_id = 1;
if ($manufacturer->save()) {
$this->comment('Manufacturer ' . $user_asset_mfgr . ' was created');
} else {
示例11: register
public function register()
{
$wantsJson = Request::wantsJson();
$creds = GoogleSessionController::getCreds();
$client = GoogleSessionController::getClient();
$code = Input::get('code');
if ($code) {
// Exchange the OAuth 2.0 authorization code for user credentials.
$client->authenticate($code);
$token = json_decode($client->getAccessToken());
$attributes = $client->verifyIdToken($token->id_token, $creds->client_id)->getAttributes();
$oauth2 = new Google_Service_Oauth2($client);
$google_user = $oauth2->userinfo->get();
$email = $google_user->email;
$username = explode("@", $email)[0];
// return Response::json(['errors'=>$user->givenName]);
if ($google_user->hd != 'ideo.com') {
$errors = ['errors' => [Config::get('config.site_name') . ' is for IDEO only']];
return $wantsJson ? Response::json($errors) : Redirect::to('register')->with($errors);
}
$user = new User();
$user->username = $username;
$user->email = $email;
$password = Hash::make($username);
// <-- temp...
$user->firstname = $google_user->givenName;
$user->lastname = $google_user->familyName;
$user->password = $password;
$user->password_confirmation = $password;
$user->confirmation_code = md5($user->username . time('U'));
$user->google_token = json_encode($token);
if ($user->save()) {
// profile image
$image_url = $google_user->picture;
if ($image_url) {
$image_url_parts = explode('?', $image_url);
$image_url = $image_url_parts[0];
$id = $user->id;
$image_name = $username . '_' . $id . '.jpg';
$save_path = 'assets/content/users';
$userImage = new Asset();
$userImage->saveRemoteImage($image_url, $save_path, $image_name);
$userImage->save();
$user->profileImage()->save($userImage);
}
// Roles
if ($username == 'tvanderlin') {
$adminRole = Role::where('name', '=', 'Admin')->first();
$user->attachRole($adminRole);
} else {
$role = $role = Role::where('name', '=', 'Writer')->first();
if ($role) {
$user->attachRole($role);
$user->save();
}
}
$back_url = 'users/' . $username;
Auth::login($user);
return Redirect::to($back_url);
} else {
return $wantsJson ? Response::json(['errors' => $user->errors()->all()]) : Redirect::to('register')->with(['errors' => $user->errors()->all()]);
}
return Response::json(['data' => $token, 'attr' => $attributes, 'user' => $user]);
}
return $wantsJson ? Response::json(['errors' => ['Missing OAuth Code']]) : Redirect::to('register')->with(['errors' => $user->errors()->all()]);
}
示例12: seedUsers
public function seedUsers()
{
$user_photos = File::files($this->seed_path);
Asset::setFromSeed(true);
foreach (User::all() as $user) {
$user->delete();
}
$faker = Faker\Factory::create();
$seeder = new LOFaker();
$n = 50;
// also creat admin users (kim & I)
$admins = array(['username' => 'tvanderlin', 'firstname' => 'Todd', 'lastname' => 'Vanderlin', 'email' => 'tvanderlin@ideo.com'], ['username' => 'kmiller', 'firstname' => 'Kim', 'lastname' => 'Miller', 'email' => 'kmiller@ideo.com']);
foreach ($admins as $data) {
$data = (object) $data;
$user = new User();
$user->timestamps = false;
$user->email = $data->email;
$user->username = $data->username;
$user->firstname = $data->firstname;
$user->lastname = $data->lastname;
$password = Hash::make($user->username);
$user->password = $password;
$user->password_confirmation = $password;
$user->confirmed = 1;
$user->confirmation_code = md5($user->username . time('U'));
$user->created_at = $user->updated_at = $faker->dateTimeBetween('-3 years', 'now');
$user->save();
$role = Role::where('name', '=', 'Admin')->first();
$user->save();
$user->attachRole($role);
$user->save();
$this->info('Creating *** Admin *** User: ' . $user->getName() . " [{$user->username}, {$user->email}]");
}
$this->info("\t");
for ($i = 0; $i < $n; $i++) {
$gender = array_random_item(['men', 'women']);
$photo = array_random_item($user_photos);
$role = Role::where('name', '=', 'Writer')->first();
$joinDate = $faker->dateTimeBetween('-3 years', 'now');
$user = new User();
$user->timestamps = false;
$user->email = 'fake_' . $faker->unique()->email;
$user->firstname = $faker->firstname;
$user->lastname = $faker->lastname;
$user->username = preg_replace("/[^A-Za-z0-9 ]/", '', $faker->unique()->userName);
$password = Hash::make($faker->password);
$user->password = $password;
$user->password_confirmation = $password;
$user->confirmed = 1;
$user->confirmation_code = md5($user->username . time('U'));
$user->created_at = $user->updated_at = $joinDate;
if ($user->save() == false) {
$this->error($user->errors() . " " . $user->username);
}
$userImage = new Asset();
$userImage->path = 'assets/content/users';
$userImage->saveLocalFile($photo, $user->username . ".jpg", Asset::ASSET_TYPE_IMAGE);
$userImage->save();
$user->profileImage()->save($userImage);
$user->profileImage->user()->associate($user);
$user->save();
$user->attachRole($role);
$user->save();
$this->info($user->id . ' Creating User: ' . $user->getName() . " [{$user->username}, {$user->email}]");
}
foreach (User::all() as $user) {
Notification::fire($user, Notification::NOTIFICATION_HALP_WELCOME);
}
}
示例13: createFakeUser
public function createFakeUser()
{
$random_user_data = (object) json_decode(get_remote_file('http://api.randomuser.me/'));
$random_user_data = $random_user_data->results[0]->user;
$faker = Faker\Factory::create();
$role = $role = Role::where('name', '=', 'Writer')->first();
$joinDate = $faker->dateTimeBetween('-3 years', 'now');
$user = new User();
$user->timestamps = false;
$user->username = $random_user_data->username;
$user->email = $random_user_data->email;
$password = Hash::make($random_user_data->username);
$user->firstname = $random_user_data->name->first;
$user->lastname = $random_user_data->name->last;
$user->password = $password;
$user->password_confirmation = $password;
$user->confirmed = 1;
$user->confirmation_code = md5($user->username . time('U'));
$user->created_at = $user->updated_at = $joinDate;
$user->save();
$image_url = $random_user_data->picture->large;
$userImage = new Asset();
$userImage->path = 'assets/content/users';
$userImage->saveRemoteAsset($image_url, $user->username . ".jpg", Asset::ASSET_TYPE_IMAGE);
$userImage->save();
$user->profileImage()->save($userImage);
$user->profileImage->user()->associate($user);
$user->save();
$user->attachRole($role);
$user->save();
return $user;
}
示例14: processImport
//.........这里部分代码省略.........
foreach ($validator->messages()->get("employee number") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("status")) {
foreach ($validator->messages()->get("status") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty start date")) {
foreach ($validator->messages()->get("warranty start date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty end date")) {
foreach ($validator->messages()->get("warranty end date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
}
if ($r->status != "Lost" && Employee::where("employee_number", "=", $r->employeenumber)->whereIn("status", array("OJT Graduate", "Graduate", "Resigned", "Obsolete"))->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign an asset to employees no longer working in the company." . "<br/>";
}
if ($r->modelid != null && !Model::where("classification_id", "=", $assetClass)->where("id", "=", $r->modelid)->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "The asset model does not belong to the selected asset type." . "<br/>";
}
if (!$rowHasError) {
$hasCorrectRows = true;
//To set image as null if asset class is not laptop.
$image = !AssetClassification::where("id", "=", $assetClass)->where("name", "=", "Laptops")->first() ? null : $r->image;
//Add the new asset
$asset = new Asset();
$asset->asset_tag = trim($r->assettag);
$asset->serial_number = trim($r->serialnumber) != null ? trim($r->serialnumber) : null;
$asset->model_id = $r->modelid != null ? $r->modelid : null;
$asset->location = $r->location != null ? $r->location : null;
$asset->employee_number = $r->employeenumber != null ? trim($r->employeenumber) : null;
$asset->warranty_start = trim($r->warrantystart) != null ? trim($r->warrantystart) : null;
$asset->warranty_end = trim($r->warrantyend) != null ? $r->warrantyend : null;
$asset->classification_id = $assetClass;
$asset->status = trim($r->status);
$asset->notes = trim($r->notes) != null ? trim($r->notes) : null;
$asset->date_added = date("Y-m-d H:i:s");
$asset->save();
//Log the new asset to asset logs
if (!empty(trim($r->employeenumber))) {
$employee = Employee::where("employee_number", "=", $r->employeenumber)->first();
$desc = "Network Asset <strong>" . $asset->asset_tag . ",</strong> SN: <strong>" . $asset->serial_number . "</strong> added to the database and assigned to employee <strong>" . $employee->first_name . " " . $employee->last_name . "</strong> with asset status <strong>" . $asset->status . "</strong>.";
} else {
$desc = "Network Asset <strong>" . $asset->asset_tag . "</strong>, SN: <strong>" . $asset->serial_number . "</strong> added to the database with status <strong>" . $asset->status . "</strong>.";
}
$assetLog = new AssetLog();
$assetLog->user_id = Session::get("user_id");
$assetLog->asset_id = $asset->id;
$assetLog->employee_id = !empty($asset->employee->id) ? $asset->employee->id : null;
$assetLog->description = $desc;
$assetLog->transaction = "History";
$assetLog->save();
//Parallel logging to system logs
$desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> added network asset <strong>" . $asset->asset_tag . "</strong>, SN: <strong>" . $asset->serial_number . "</strong> ";
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
}
}
File::delete($readFile);
if ($hasCorrectRows) {
//Log the changes made
$desc = "(" . Session::get("user_type") . ") <b>" . Session::get("username") . "</b> has imported data to network assets database. ";
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->save();
}
return $this->importResult($hasError, $hasCorrectRows, $rowsWithErrors, $error);
}
} else {
return Redirect::to('/');
}
}
示例15: foreach
/**
* update_images()
* Updates the image details for an entire image set (thumbnail, small, image) */
function update_images($images)
{
if (!is_array($images)) {
return false;
}
$db = DB::get();
$table = DatabaseObject::tablename(Asset::$table);
foreach ($images as $i => $img) {
$query = "SELECT imgs.id FROM {$table} AS thumb LEFT JOIN {$table} AS imgs ON thumb.src=imgs.src OR thumb.src=imgs.id WHERE thumb.id={$img['id']}";
$imageset = $db->query($query);
foreach ($imageset as $is) {
$Image = new Asset();
unset($Image->_datatypes['data'], $Image->data);
$Image->load($is->id);
$Image->properties['title'] = $img['title'];
$Image->properties['alt'] = $img['alt'];
$Image->save();
}
}
return true;
}