function _avatar_selection_save_avatar_info in Avatar Selection 7
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()
- 6 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.
$fid: The managed file id
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 807 - Administrative page callbacks for the avatar_selection module.
Code
function _avatar_selection_save_avatar_info($aid, $image, $name, $access, $og = array(), $weight = 0, $fid = NULL) {
// Add or update avatar_selection table.
if ($aid) {
$result = db_update('avatar_selection')
->fields(array(
'name' => $name,
'weight' => $weight,
))
->condition('aid', $aid)
->execute();
$result = db_delete('avatar_selection_roles')
->condition('aid', $aid)
->execute();
$result = db_delete('avatar_selection_og')
->condition('aid', $aid)
->execute();
}
else {
$aid = db_insert('avatar_selection')
->fields(array(
'avatar' => $image,
'name' => $name,
'weight' => $weight,
'fid' => $fid,
))
->execute();
}
// Add access settings.
if (is_array($access) && count($access)) {
foreach ($access as $rid) {
$id = db_insert('avatar_selection_roles')
->fields(array(
'aid' => $aid,
'rid' => $rid,
))
->execute();
}
}
if (is_array($og) && count($og)) {
foreach ($og as $ogid) {
$id = db_insert('avatar_selection_og')
->fields(array(
'aid' => $aid,
'ogid' => $ogid,
))
->execute();
}
}
}