function _avatar_selection_save_avatar_info in Avatar Selection 6
Same name and namespace in other branches
- 5.2 avatar_selection.module \_avatar_selection_save_avatar_info()
- 5 avatar_selection.module \_avatar_selection_save_avatar_info()
- 7 avatar_selection.admin.inc \_avatar_selection_save_avatar_info()
Create the SQL queries in order to save the avatar path and data into the database, and perform them according to the SQL server type.
Parameters
$aid: The avatar identifier.
$image: The avatar image.
$name: The avatar name, used as the image alternative text on the forms.
$access: Array of roles - the value determines which user roles have rights to see the avatar.
$og: Array of organic groups (optional).
$weight: The weight of the avatar. Lower weighted avatars appear before higher weighted avatars in the list.
3 calls to _avatar_selection_save_avatar_info()
- avatar_selection_edit_update_form_submit in ./
avatar_selection.admin.inc - Submit the image list form in the Avatar Selection - 'Manage Avatars' page.
- avatar_selection_upload_form_submit in ./
avatar_selection.admin.inc - Submit the image upload form in the Avatar Selection administration page.
- _avatar_selection_scan_images in ./
avatar_selection.admin.inc - Scan the directory for new files.
File
- ./
avatar_selection.admin.inc, line 745 - Administrative page callbacks for the avatar_selection module.
Code
function _avatar_selection_save_avatar_info($aid, $image, $name, $access, $og = array(), $weight = 0) {
// Add or update avatar_selection table.
if ($aid) {
$result = db_query("UPDATE {avatar_selection} SET name = '%s', weight = %d WHERE aid = %d AND avatar = '%s'", $name, $weight, $aid, $image);
$result = db_query("DELETE FROM {avatar_selection_roles} WHERE aid = %d", $aid);
$result = db_query("DELETE FROM {avatar_selection_og} WHERE aid = %d", $aid);
}
else {
$result = db_query("INSERT INTO {avatar_selection} (avatar, name, weight) VALUES('%s', '%s', %d)", $image, $name, $weight);
$aid = db_last_insert_id('avatar_selection', 'aid');
}
// Add access settings.
if (is_array($access) && count($access)) {
foreach ($access as $rid) {
$result = db_query("INSERT INTO {avatar_selection_roles} (aid, rid) VALUES(%d, %d)", $aid, $rid);
}
}
if (is_array($og) && count($og)) {
foreach ($og as $ogid) {
$result = db_query("INSERT INTO {avatar_selection_og} (aid, ogid) VALUES(%d, %d)", $aid, $ogid);
}
}
}