当前位置: 首页>>代码示例>>PHP>>正文


PHP Okapi::logtypename2id方法代码示例

本文整理汇总了PHP中okapi\Okapi::logtypename2id方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::logtypename2id方法的具体用法?PHP Okapi::logtypename2id怎么用?PHP Okapi::logtypename2id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在okapi\Okapi的用法示例。


在下文中一共展示了Okapi::logtypename2id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_found_cache_ids

 /**
  * Get the list of cache IDs which were found by given user.
  * Parameter needs to be *internal* user id, not uuid.
  */
 private static function get_found_cache_ids($internal_user_id)
 {
     return Db::select_column("\n            select cache_id\n            from cache_logs\n            where\n                user_id = '" . mysql_real_escape_string($internal_user_id) . "'\n                and type in (\n                    '" . mysql_real_escape_string(Okapi::logtypename2id("Found it")) . "',\n                    '" . mysql_real_escape_string(Okapi::logtypename2id("Attended")) . "'\n                )\n                and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "deleted = 0" : "true") . "\n        ");
 }
开发者ID:harrieklomp,项目名称:oc-server3,代码行数:8,代码来源:searching.inc.php

示例2: call


//.........这里部分代码省略.........
                 case 'internal_id':
                     $entry['internal_id'] = $row['cache_id'];
                     break;
                 case 'attribution_note':
                     /* handled separately */
                     break;
                 case 'protection_areas':
                     /* handled separately */
                     break;
                 default:
                     throw new Exception("Missing field case: " . $field);
             }
         }
         $results[$row['wp_oc']] = $entry;
     }
     mysql_free_result($rs);
     # owner
     if (in_array('owner', $fields) && count($results) > 0) {
         $rs = Db::query("\n                select user_id, uuid, username\n                from user\n                where user_id in ('" . implode("','", array_map('mysql_real_escape_string', array_values($owner_ids))) . "')\n            ");
         $tmp = array();
         while ($row = mysql_fetch_assoc($rs)) {
             $tmp[$row['user_id']] = $row;
         }
         foreach ($results as $cache_code => &$result_ref) {
             $row = $tmp[$owner_ids[$cache_code]];
             $result_ref['owner'] = array('uuid' => $row['uuid'], 'username' => $row['username'], 'profile_url' => Settings::get('SITE_URL') . "viewprofile.php?userid=" . $row['user_id']);
         }
     }
     # is_found
     if (in_array('is_found', $fields)) {
         if ($user_id == null) {
             throw new BadRequest("Either 'user_uuid' parameter OR Level 3 Authentication is required to access 'is_found' field.");
         }
         $tmp = Db::select_column("\n                select c.wp_oc\n                from\n                    caches c,\n                    cache_logs cl\n                where\n                    c.cache_id = cl.cache_id\n                    and cl.type in (\n                        '" . mysql_real_escape_string(Okapi::logtypename2id("Found it")) . "',\n                        '" . mysql_real_escape_string(Okapi::logtypename2id("Attended")) . "'\n                    )\n                    and cl.user_id = '" . mysql_real_escape_string($user_id) . "'\n                    " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "and cl.deleted = 0" : "") . "\n            ");
         $tmp2 = array();
         foreach ($tmp as $cache_code) {
             $tmp2[$cache_code] = true;
         }
         foreach ($results as $cache_code => &$result_ref) {
             $result_ref['is_found'] = isset($tmp2[$cache_code]);
         }
     }
     # is_not_found
     if (in_array('is_not_found', $fields)) {
         if ($user_id == null) {
             throw new BadRequest("Either 'user_uuid' parameter OR Level 3 Authentication is required to access 'is_not_found' field.");
         }
         $tmp = Db::select_column("\n                select c.wp_oc\n                from\n                    caches c,\n                    cache_logs cl\n                where\n                    c.cache_id = cl.cache_id\n                    and cl.type = '" . mysql_real_escape_string(Okapi::logtypename2id("Didn't find it")) . "'\n                    and cl.user_id = '" . mysql_real_escape_string($user_id) . "'\n                    " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "and cl.deleted = 0" : "") . "\n            ");
         $tmp2 = array();
         foreach ($tmp as $cache_code) {
             $tmp2[$cache_code] = true;
         }
         foreach ($results as $cache_code => &$result_ref) {
             $result_ref['is_not_found'] = isset($tmp2[$cache_code]);
         }
     }
     # is_watched
     if (in_array('is_watched', $fields)) {
         if ($request->token == null) {
             throw new BadRequest("Level 3 Authentication is required to access 'is_watched' field.");
         }
         $tmp = Db::select_column("\n                select c.wp_oc\n                from\n                    caches c,\n                    cache_watches cw\n                where\n                    c.cache_id = cw.cache_id\n                    and cw.user_id = '" . mysql_real_escape_string($request->token->user_id) . "'\n            ");
         $tmp2 = array();
         foreach ($tmp as $cache_code) {
             $tmp2[$cache_code] = true;
         }
开发者ID:Slini11,项目名称:okapi,代码行数:67,代码来源:geocaches.php

示例3: get_found_cache_ids

 /**
  * Get the list of cache IDs which were found by given user.
  * Parameter needs to be *internal* user id, not uuid.
  */
 private static function get_found_cache_ids($internal_user_ids)
 {
     return Db::select_column("\n            select cache_id\n            from cache_logs\n            where\n                user_id in ('" . implode("','", array_map('\\okapi\\Db::escape_string', $internal_user_ids)) . "')\n                and type in (\n                    '" . Db::escape_string(Okapi::logtypename2id("Found it")) . "',\n                    '" . Db::escape_string(Okapi::logtypename2id("Attended")) . "'\n                )\n                and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "deleted = 0" : "true") . "\n        ");
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:8,代码来源:searching.inc.php

示例4: insert_log_row

 private static function insert_log_row($consumer_key, $cache_internal_id, $user_internal_id, $logtype, $when, $formatted_comment, $text_html)
 {
     $log_uuid = self::create_uuid();
     Db::execute("\n            insert into cache_logs (uuid, cache_id, user_id, type, date, text, text_html, last_modified, date_created, node)\n            values (\n                '" . mysql_real_escape_string($log_uuid) . "',\n                '" . mysql_real_escape_string($cache_internal_id) . "',\n                '" . mysql_real_escape_string($user_internal_id) . "',\n                '" . mysql_real_escape_string(Okapi::logtypename2id($logtype)) . "',\n                from_unixtime('" . mysql_real_escape_string($when) . "'),\n                '" . mysql_real_escape_string($formatted_comment) . "',\n                '" . mysql_real_escape_string($text_html) . "',\n                now(),\n                now(),\n                '" . mysql_real_escape_string(Settings::get('OC_NODE_ID')) . "'\n            );\n        ");
     $log_internal_id = Db::last_insert_id();
     # Store additional information on consumer_key which have created this log entry.
     # (Maybe we'll want to display this somewhere later.)
     Db::execute("\n            insert into okapi_cache_logs (log_id, consumer_key)\n            values (\n                '" . mysql_real_escape_string($log_internal_id) . "',\n                '" . mysql_real_escape_string($consumer_key) . "'\n            );\n        ");
     return $log_uuid;
 }
开发者ID:4Vs,项目名称:oc-server3,代码行数:10,代码来源:submit.php

示例5: call

 public static function call(OkapiRequest $request)
 {
     $log_uuids = $request->get_parameter('log_uuids');
     if ($log_uuids === null) {
         throw new ParamMissing('log_uuids');
     }
     if ($log_uuids === "") {
         $log_uuids = array();
     } else {
         $log_uuids = explode("|", $log_uuids);
     }
     if (count($log_uuids) > 500 && !$request->skip_limits) {
         throw new InvalidParam('log_uuids', "Maximum allowed number of referenced " . "log entries is 500. You provided " . count($log_uuids) . " UUIDs.");
     }
     if (count($log_uuids) != count(array_unique($log_uuids))) {
         throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
     }
     $fields = $request->get_parameter('fields');
     if (!$fields) {
         $fields = "date|user|type|comment";
     }
     $fields = explode("|", $fields);
     foreach ($fields as $field) {
         if (!in_array($field, self::$valid_field_names)) {
             throw new InvalidParam('fields', "'{$field}' is not a valid field code.");
         }
     }
     if (Settings::get('OC_BRANCH') == 'oc.de') {
         $teamentry_field = 'cl.oc_team_comment';
         $ratingdate_condition = 'and cr.rating_date=cl.date';
         $needs_maintenance_SQL = 'cl.needs_maintenance';
         $listing_is_outdated_SQL = 'cl.listing_outdated';
     } else {
         $teamentry_field = '(cl.type=12)';
         $ratingdate_condition = '';
         $needs_maintenance_SQL = 'IF(cl.type=5, 2, IF(cl.type=6, 1, 0))';
         $listing_is_outdated_SQL = '0';
     }
     $rs = Db::query("\n            select\n                cl.id, c.wp_oc as cache_code, cl.uuid, cl.type,\n                " . $teamentry_field . " as oc_team_entry,\n                " . $needs_maintenance_SQL . " as needs_maintenance2,\n                " . $listing_is_outdated_SQL . " as listing_is_outdated,\n                unix_timestamp(cl.date) as date, cl.text,\n                u.uuid as user_uuid, u.username, u.user_id,\n                if(cr.user_id is null, 0, 1) as was_recommended\n            from\n                (cache_logs cl,\n                user u,\n                caches c)\n                left join cache_rating cr\n                    on cr.user_id = u.user_id\n                    and cr.cache_id = c.cache_id\n                    " . $ratingdate_condition . "\n                    and cl.type in (\n                        " . Okapi::logtypename2id("Found it") . ",\n                        " . Okapi::logtypename2id("Attended") . "\n                    )\n            where\n                cl.uuid in ('" . implode("','", array_map('\\okapi\\Db::escape_string', $log_uuids)) . "')\n                and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "cl.deleted = 0" : "true") . "\n                and cl.user_id = u.user_id\n                and c.cache_id = cl.cache_id\n                and c.status in (1,2,3)\n        ");
     $results = array();
     $log_id2uuid = array();
     /* Maps logs' internal_ids to uuids */
     $flag_options = array('null', 'false', 'true');
     while ($row = Db::fetch_assoc($rs)) {
         $results[$row['uuid']] = array('uuid' => $row['uuid'], 'cache_code' => $row['cache_code'], 'date' => date('c', $row['date']), 'user' => array('uuid' => $row['user_uuid'], 'username' => $row['username'], 'profile_url' => Settings::get('SITE_URL') . "viewprofile.php?userid=" . $row['user_id']), 'type' => Okapi::logtypeid2name($row['type']), 'was_recommended' => $row['was_recommended'] ? true : false, 'needs_maintenance2' => $flag_options[$row['needs_maintenance2']], 'listing_is_outdated' => $flag_options[$row['listing_is_outdated']], 'oc_team_entry' => $row['oc_team_entry'] ? true : false, 'comment' => Okapi::fix_oc_html($row['text'], Okapi::OBJECT_TYPE_CACHE_LOG), 'images' => array(), 'internal_id' => $row['id']);
         $log_id2uuid[$row['id']] = $row['uuid'];
     }
     Db::free_result($rs);
     # fetch images
     if (in_array('images', $fields)) {
         # For OCPL log entry images, pictures.seq currently is always = 1,
         # while OCDE uses it for ordering the images.
         $rs = Db::query("\n                select object_id, uuid, url, title, spoiler\n                from pictures\n                where\n                    object_type = 1\n                    and object_id in ('" . implode("','", array_map('\\okapi\\Db::escape_string', array_keys($log_id2uuid))) . "')\n                    and display = 1   /* currently is always 1 for logpix */\n                    and unknown_format = 0\n                order by seq, date_created\n            ");
         if (Settings::get('OC_BRANCH') == 'oc.de') {
             $object_type_param = 'type=1&';
         } else {
             $object_type_param = '';
         }
         while ($row = Db::fetch_assoc($rs)) {
             $results[$log_id2uuid[$row['object_id']]]['images'][] = array('uuid' => $row['uuid'], 'url' => $row['url'], 'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?' . $object_type_param . 'uuid=' . $row['uuid'], 'caption' => $row['title'], 'is_spoiler' => $row['spoiler'] ? true : false);
         }
         Db::free_result($rs);
     }
     # Check which UUIDs were not found and mark them with null.
     foreach ($log_uuids as $log_uuid) {
         if (!isset($results[$log_uuid])) {
             $results[$log_uuid] = null;
         }
     }
     # Remove unwanted fields.
     foreach (self::$valid_field_names as $field) {
         if (!in_array($field, $fields)) {
             foreach ($results as &$result_ref) {
                 unset($result_ref[$field]);
             }
         }
     }
     # Order the results in the same order as the input codes were given.
     $ordered_results = array();
     foreach ($log_uuids as $log_uuid) {
         $ordered_results[$log_uuid] = $results[$log_uuid];
     }
     return Okapi::formatted_response($request, $ordered_results);
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:84,代码来源:entries.php

示例6: insert_log_row

 private static function insert_log_row($consumer_key, $cache_internal_id, $user_internal_id, $logtype, $when, $formatted_comment, $text_html, $needs_maintenance2)
 {
     if (Settings::get('OC_BRANCH') == 'oc.de') {
         $needs_maintenance_field_SQL = ', needs_maintenance';
         if ($needs_maintenance2 == 'true') {
             $needs_maintenance_SQL = ',2';
         } else {
             if ($needs_maintenance2 == 'false') {
                 $needs_maintenance_SQL = ',1';
             } else {
                 // 'null'
                 $needs_maintenance_SQL = ',0';
             }
         }
     } else {
         $needs_maintenance_field_SQL = '';
         $needs_maintenance_SQL = '';
     }
     $log_uuid = Okapi::create_uuid();
     Db::execute("\n            insert into cache_logs (\n                uuid, cache_id, user_id, type, date, text, text_html,\n                last_modified, date_created, node" . $needs_maintenance_field_SQL . "\n            ) values (\n                '" . Db::escape_string($log_uuid) . "',\n                '" . Db::escape_string($cache_internal_id) . "',\n                '" . Db::escape_string($user_internal_id) . "',\n                '" . Db::escape_string(Okapi::logtypename2id($logtype)) . "',\n                from_unixtime('" . Db::escape_string($when) . "'),\n                '" . Db::escape_string($formatted_comment) . "',\n                '" . Db::escape_string($text_html) . "',\n                now(),\n                now(),\n                '" . Db::escape_string(Settings::get('OC_NODE_ID')) . "'\n                " . $needs_maintenance_SQL . "\n            );\n        ");
     $log_internal_id = Db::last_insert_id();
     # Store additional information on consumer_key which has created this log entry.
     # (Maybe we'll want to display this somewhen later.)
     Db::execute("\n            insert into okapi_submitted_objects (object_type, object_id, consumer_key)\n            values (\n                " . Okapi::OBJECT_TYPE_CACHE_LOG . ",\n                '" . Db::escape_string($log_internal_id) . "',\n                '" . Db::escape_string($consumer_key) . "'\n            );\n        ");
     return $log_uuid;
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:26,代码来源:submit.php


注:本文中的okapi\Okapi::logtypename2id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。