// groups granted to access the category $query = ' SELECT group_id FROM ' . GROUP_ACCESS_TABLE . ' WHERE cat_id = ' . $page['cat'] . ' ;'; $group_granted_ids = array_from_query($query, 'group_id'); $template->assign('groups_selected', $group_granted_ids); // users... $users = array(); $query = ' SELECT ' . $conf['user_fields']['id'] . ' AS id, ' . $conf['user_fields']['username'] . ' AS username FROM ' . USERS_TABLE . ' ;'; $users = simple_hash_from_query($query, 'id', 'username'); $template->assign('users', $users); $query = ' SELECT user_id FROM ' . USER_ACCESS_TABLE . ' WHERE cat_id = ' . $page['cat'] . ' ;'; $user_granted_direct_ids = array_from_query($query, 'user_id'); $template->assign('users_selected', $user_granted_direct_ids); $user_granted_indirect_ids = array(); if (count($group_granted_ids) > 0) { $granted_groups = array(); $query = ' SELECT user_id, group_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id IN (' . implode(',', $group_granted_ids) . ')
// +-----------------------------------------------------------------------+ // | files / elements | // +-----------------------------------------------------------------------+ if (isset($_POST['submit']) and $_POST['sync'] == 'files' and !$general_failure) { $start_files = get_moment(); $start = $start_files; $fs = $site_reader->get_elements($basedir); $template->append('footer_elements', '<!-- get_elements: ' . get_elapsed_time($start, get_moment()) . ' -->'); $cat_ids = array_diff(array_keys($db_categories), $to_delete); $db_elements = array(); if (count($cat_ids) > 0) { $query = ' SELECT id, path FROM ' . IMAGES_TABLE . ' WHERE storage_category_id IN (' . wordwrap(implode(', ', $cat_ids), 160, "\n") . ')'; $db_elements = simple_hash_from_query($query, 'id', 'path'); } // next element id available $next_element_id = pwg_db_nextval('id', IMAGES_TABLE); $start = get_moment(); $inserts = array(); $insert_links = array(); foreach (array_diff(array_keys($fs), $db_elements) as $path) { $insert = array(); // storage category must exist $dirname = dirname($path); if (!isset($db_fulldirs[$dirname])) { continue; } $filename = basename($path); if (!preg_match($conf['sync_chars_regex'], $filename)) {
if (count($group_ids) == 0) { $template->assign('permission_url', $admin_album_base_url . '-permissions'); } } else { $group_ids = $all_group_ids; } if (count($group_ids) > 0) { $query = ' SELECT id, name FROM ' . GROUPS_TABLE . ' WHERE id IN (' . implode(',', $group_ids) . ') ORDER BY name ASC ;'; $template->assign('group_mail_options', simple_hash_from_query($query, 'id', 'name')); } } // all users with status != guest and permitted to this this album (for a // perfect search, we should also check that album is not only filled with // private photos) $query = ' SELECT user_id FROM ' . USER_INFOS_TABLE . ' WHERE status != \'guest\' ;'; $all_user_ids = query2array($query, null, 'user_id'); if ('private' == $category['status']) { $user_ids_access_indirect = array(); if (isset($group_ids) and count($group_ids) > 0) {
$all_albums = $all_albums['photoset']; $all_photos = array(); foreach ($all_albums as $album) { $album_photos = $flickr->photosets_getPhotos($album['id'], NULL, NULL, 500, NULL, 'photos'); $album_photos = $album_photos['photoset']['photo']; foreach ($album_photos as $photo) { $all_photos[$photo['id']][] = $album['title']; } } // get existing photos $query = ' SELECT id, file FROM ' . IMAGES_TABLE . ' WHERE file LIKE "' . $flickr_prefix . '%" ;'; $existing_photos = simple_hash_from_query($query, 'id', 'file'); $existing_photos = array_map(create_function('$p', 'return preg_replace("#^' . $flickr_prefix . '([0-9]+)\\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos); // remove existing photos $duplicates = 0; foreach ($all_photos as $id => &$photo) { if (in_array($id, $existing_photos)) { unset($all_photos[$id]); $duplicates++; } else { $photo = array('id' => $id, 'albums' => implode(',', $photo)); } } unset($photo); $all_photos = array_values($all_photos); if ($duplicates > 0) { $page['infos'][] = '<a href="admin.php?page=batch_manager&filter=prefilter-flickr">' . l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates) . '</a>';
$orphan_tag_names = array(); foreach ($orphan_tags as $tag) { $orphan_tag_names[] = trigger_change('render_tag_name', $tag['name'], $tag); } if (count($orphan_tag_names) > 0) { $page['warnings'][] = sprintf(l10n('You have %d orphan tags: %s.') . ' <a href="%s">' . l10n('Delete orphan tags') . '</a>', count($orphan_tag_names), implode(', ', $orphan_tag_names), get_root_url() . 'admin.php?page=tags&action=delete_orphans&pwg_token=' . get_pwg_token()); } // +-----------------------------------------------------------------------+ // | form creation | // +-----------------------------------------------------------------------+ // tag counters $query = ' SELECT tag_id, COUNT(image_id) AS counter FROM ' . IMAGE_TAG_TABLE . ' GROUP BY tag_id'; $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter'); // all tags $query = ' SELECT * FROM ' . TAGS_TABLE . ' ;'; $result = pwg_query($query); $all_tags = array(); while ($tag = pwg_db_fetch_assoc($result)) { $raw_name = $tag['name']; $tag['name'] = trigger_change('render_tag_name', $raw_name, $tag); $tag['counter'] = intval(@$tag_counters[$tag['id']]); $tag['U_VIEW'] = make_index_url(array('tags' => array($tag))); $tag['U_EDIT'] = 'admin.php?page=batch_manager&filter=tag-' . $tag['id']; $alt_names = trigger_change('get_tag_alt_names', array(), $raw_name); $alt_names = array_diff(array_unique($alt_names), array($tag['name']));
/** * API method * Check if an image exists by it's name or md5 sum * @param mixed[] $params * @option string md5sum_list (optional) * @option string filename_list (optional) */ function ws_images_exist($params, $service) { ws_logfile(__FUNCTION__ . ' ' . var_export($params, true)); global $conf; $split_pattern = '/[\\s,;\\|]/'; $result = array(); if ('md5sum' == $conf['uniqueness_mode']) { // search among photos the list of photos already added, based on md5sum list $md5sums = preg_split($split_pattern, $params['md5sum_list'], -1, PREG_SPLIT_NO_EMPTY); $query = ' SELECT id, md5sum FROM ' . IMAGES_TABLE . ' WHERE md5sum IN (\'' . implode("','", $md5sums) . '\') ;'; $id_of_md5 = simple_hash_from_query($query, 'md5sum', 'id'); foreach ($md5sums as $md5sum) { $result[$md5sum] = null; if (isset($id_of_md5[$md5sum])) { $result[$md5sum] = $id_of_md5[$md5sum]; } } } else { if ('filename' == $conf['uniqueness_mode']) { // search among photos the list of photos already added, based on // filename list $filenames = preg_split($split_pattern, $params['filename_list'], -1, PREG_SPLIT_NO_EMPTY); $query = ' SELECT id, file FROM ' . IMAGES_TABLE . ' WHERE file IN (\'' . implode("','", $filenames) . '\') ;'; $id_of_filename = simple_hash_from_query($query, 'file', 'id'); foreach ($filenames as $filename) { $result[$filename] = null; if (isset($id_of_filename[$filename])) { $result[$filename] = $id_of_filename[$filename]; } } } } return $result; }